From a8b7626495c5b265c20ef81af79bffe63f76f26c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 16:51:17 +0100 Subject: [PATCH 1/7] chore: update Node.js SDK to 30.0.0 --- CHANGELOG.md | 56 +- README.md | 4 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 1 + docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../project/create-android-platform.md | 1 + .../project/update-android-platform.md | 1 + .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 50 +- src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 2 + src/models.ts | 567 ++- src/services/account.ts | 2215 ++++++++++- src/services/activities.ts | 101 +- src/services/advisor.ts | 221 +- src/services/apps.ts | 621 ++- src/services/avatars.ts | 1 + src/services/backups.ts | 241 +- src/services/databases.ts | 1536 +++++++- src/services/documents-db.ts | 1016 ++++- src/services/domains.ts | 1376 ++++++- src/services/embeddings.ts | 34 +- src/services/functions.ts | 875 ++++- src/services/locale.ts | 204 +- src/services/messaging.ts | 1139 +++++- src/services/mongo.ts | 1076 +++++- src/services/mysql.ts | 1151 +++++- src/services/oauth-2.ts | 321 +- src/services/organization.ts | 671 +++- src/services/postgresql.ts | 1295 ++++++- src/services/presences.ts | 89 +- src/services/project.ts | 3372 ++++++++++++++++- src/services/proxy.ts | 216 +- src/services/sites.ts | 815 +++- src/services/storage.ts | 216 +- src/services/tables-db.ts | 1873 ++++++++- src/services/teams.ts | 369 +- src/services/tokens.ts | 97 +- src/services/users.ts | 1731 ++++++++- src/services/vectors-db.ts | 1011 ++++- src/services/waf.ts | 2414 ++++++++++++ src/services/webhooks.ts | 163 +- test/services/account.test.js | 123 + test/services/documents-d-b.test.js | 4 - test/services/mongo.test.js | 46 - test/services/mysql.test.js | 46 - test/services/organization.test.js | 14 - test/services/postgresql.test.js | 54 - test/services/project.test.js | 79 +- test/services/tables-d-b.test.js | 4 - test/services/users.test.js | 59 + test/services/vectors-d-b.test.js | 4 - test/services/waf.test.js | 354 ++ 90 files changed, 27371 insertions(+), 1068 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..2610013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,54 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - ## 30.0.0 * Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed +* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey` +* Breaking: `OrganizationKeyScopes` enum removed * Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed * Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` +* Breaking: `DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList.pricing` removed; rates live on `DedicatedDatabaseSpecification` * Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model +* Breaking: `resource` on `oauth2` authorize, PAR, device and token methods is now `string[]` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: deprecated positional arguments shift on `teams.createMembership`, `messaging` email/push/SMS and `project.updateOAuth2*` +* Added: `account` passkey methods: `createPasskey`, `updatePasskeyVerification`, `createPasskeyToken`, `updatePasskeyToken` +* Added: `account.listPasskeys`, `getPasskey`, `updatePasskey` and `deletePasskey` +* Added: `users.listPasskeys`, `getPasskey`, `updatePasskey` and `deletePasskey` +* Added: `project.updatePasskeyPolicy` and `passkey` policy and auth method IDs +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge`, `PolicyPasskey` and `TokenSecret` models +* Added: `fingerprints` on Android platform create and update, and on `PlatformAndroid` +* Added: `waf` service for bypass, challenge, deny, rate limit and redirect rules * Added: `domains` service for domains, DNS records, email presets, prices and transfers +* Added: `oauth2.introspect` returning the `Oauth2Introspection` model * Added: `account.createIdTokenSession` and email verification and recovery OTP methods * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers +* Added: `project.updatePasswordPwnedPolicy`, `PolicyPasswordPwned` and `User.passwordPwned` +* Added: Kakao, TikTok and Webflow OAuth2 providers, and `prompt` enums per provider * Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: `membershipId` on `teams.createMembership` +* Added: reply-to on email messages, `channelId` on push, `qos` and `expiry` on topics +* Added: optional `total` on locale and list endpoints, `duration` on email-password sessions +* Added: `Topic`, `ResolvedTopic` and `Models.Account` exports +* Added: `analytics.read`, `analytics.write`, `avatars.write` and `dedicatedDatabases.execute` key scopes +* Added: storage resize fields on `DedicatedDatabase`, `firstAccessedAt` and `mcpAccessedAt` on `Project` * Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: `project.updatePasswordRotationPolicy` and the `PolicyPasswordRotation` model +* Fixed: response models fill missing fields from spec defaults instead of throwing +* Fixed: object values in multipart requests are sent as JSON +* Updated: `chunkedUpload` supports a `text` response type and works without a file +* Updated: several `Organization`, `UsageBillingPlan` and dedicated database model fields are now optional +* Updated: requests send `X-Appwrite-Response-Format` `2.4.0` + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..6374da1 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.4.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.4.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '', // optional + name: '', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '', + name: '', +}); +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..78a1de6 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,6 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional }); ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '', name: '', applicationId: '', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '', name: '', applicationId: '', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..c859bec 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -11,6 +11,7 @@ const teams = new sdk.Teams(client); const result = await teams.createMembership({ teamId: '', roles: ['editor'], + membershipId: '', // optional email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.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 users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '', + passkeyId: '', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.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 users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '', + passkeyId: '', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.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 users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.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 users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '', + passkeyId: '', + name: '', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '', + resourceType: 'api', + name: '', + limit: 1, + interval: 1, + resourceId: '', // optional + description: '', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '', + resourceType: 'api', + name: '', + location: '', + statusCode: 300, + resourceId: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '', + resourceType: 'api', // optional + resourceId: '', // optional + name: '', // optional + description: '', // optional + location: '', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..b36b64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..9272cdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..2eefc67 100644 --- a/src/client.ts +++ b/src/client.ts @@ -44,6 +44,50 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record; + properties?: Record; +}; + +type Defaults = { + root: DefaultsShape; + models: Record; +}; + +export function applyDefaults(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record = { ...model.defaults, ...value }; + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +124,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +185,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.4.0', }; /** diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..35f0b73 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,7 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; @@ -119,3 +120,4 @@ export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..6a00134 100644 --- a/src/models.ts +++ b/src/models.ts @@ -25,6 +25,7 @@ import { ProxyRuleStatus } from './enums/proxy-rule-status'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +504,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +516,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -4201,6 +4204,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number; /** * Function execution timeout in seconds. */ @@ -6251,6 +6258,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6406,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6568,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6931,6 +6978,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -8021,6 +8164,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8266,7 +8413,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8555,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string; /** * Database engine version. */ @@ -8432,7 +8579,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number; /** * Database username for connections. */ @@ -8444,7 +8591,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number; /** * Full database connection string (URI format). */ @@ -8658,7 +8805,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string; /** * Project ID. */ @@ -8666,7 +8813,7 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ @@ -8678,15 +8825,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string; /** * Error message if restoration failed. */ @@ -9148,15 +9295,15 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string; /** * Start date of trial. */ @@ -9164,19 +9311,19 @@ export namespace Models { /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string; /** * Default payment method. */ @@ -9622,11 +9769,11 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource; /** * Member additional resources */ @@ -9634,11 +9781,11 @@ export namespace Models { /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource; /** * Realtime bandwidth additional resources */ @@ -9646,19 +9793,19 @@ export namespace Models { /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource; /** * Credits additional resources */ @@ -10289,6 +10436,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..5495849 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +185,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +295,38 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +381,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +539,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +644,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +820,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +930,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1078,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1178,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1248,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1341,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1462,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1675,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1749,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1841,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1957,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2017,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2052,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2088,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2119,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2152,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2184,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2217,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2249,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2321,536 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @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. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPasskey(params: { passkeyId: string }): Promise; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2929,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3050,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3176,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3286,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3397,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3488,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3597,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3665,57 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3787,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2470,7 +3918,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4120,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4235,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4347,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4458,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4553,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4649,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4765,49 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4898,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5022,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5055,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} */ @@ -3259,6 +5064,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: 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. @@ -3273,6 +5079,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5089,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5098,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5118,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5134,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5142,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5162,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5175,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createPasskeyToken(): Promise { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5375,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5452,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5530,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5621,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5710,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5787,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5880,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5917,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6008,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..e0b9039 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,57 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +170,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..5e01ab0 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,73 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +203,63 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +400,54 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +519,43 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..f7e4461 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,70 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +448,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +520,33 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +565,33 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +642,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1013,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1199,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1303,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1470,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1567,36 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1650,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1729,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1880,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2014,36 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2097,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2184,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2334,60 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 6faed76..5fa9e52 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..87d5ef2 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,7 +64,34 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -135,7 +167,24 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +239,24 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +363,36 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +555,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,7 +629,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +765,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +966,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1038,36 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1124,25 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..7f65790 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,64 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +241,54 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +357,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +437,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +512,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +619,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +769,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +842,54 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +974,54 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1181,54 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1053,7 +1398,44 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1512,44 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1695,44 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1917,19 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1638,7 +2106,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1818,7 +2303,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1963,7 +2465,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2109,7 +2628,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2252,7 +2788,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2398,7 +2951,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3113,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2691,7 +3279,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2853,7 +3459,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3018,7 +3642,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3195,7 +3837,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3375,7 +4034,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3552,7 +4228,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3732,7 +4425,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3877,7 +4587,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4025,7 +4753,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4156,7 +4902,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4297,7 +5060,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4454,7 +5234,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4602,7 +5399,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4759,7 +5573,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4907,7 +5738,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5038,7 +5886,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5179,7 +6044,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5310,7 +6192,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5451,7 +6350,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5628,7 +6544,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5754,7 +6692,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5934,7 +6894,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6094,7 +7072,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6251,7 +7247,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6399,7 +7412,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6544,7 +7574,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6692,7 +7740,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6872,7 +7938,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +8116,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8508,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7576,7 +8705,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7694,7 +8840,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7814,7 +8987,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7939,7 +9139,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9279,34 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9436,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8352,7 +9623,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8522,7 +9810,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8798,7 +10103,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8957,7 +10279,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,7 +10406,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9234,7 +10602,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10711,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..bb8ed5c 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,64 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +268,54 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +334,41 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +436,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +515,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +589,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +695,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +843,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +915,54 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1094,54 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1299,54 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1136,7 +1515,44 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1628,44 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1813,44 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2059,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2255,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2389,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2535,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2686,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2825,34 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +2981,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3167,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3353,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3644,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3819,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3945,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4140,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4248,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3637,7 +4431,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4591,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4677,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4760,49 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..8d3180e 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,60 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +197,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +331,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +440,34 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +520,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +694,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +797,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +897,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +992,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1082,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1175,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1265,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1358,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1448,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1541,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1631,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1724,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1812,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1905,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2012,40 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2173,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2339,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2490,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2656,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2809,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2979,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3130,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3296,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3453,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3615,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3766,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3932,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4104,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4283,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4434,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4602,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4802,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5046,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5196,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5364,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5465,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5639,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5739,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5885,49 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..cdc8d3e 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,31 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..c46c201 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,76 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +177,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +194,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} */ @@ -150,6 +221,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: 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. @@ -159,7 +231,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +248,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +276,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise; create( paramsOrFirst: @@ -229,6 +303,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +328,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise { let params: { @@ -278,6 +354,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +385,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +411,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +437,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +519,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +530,66 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +640,35 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +736,32 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +816,66 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +886,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -649,6 +903,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} */ @@ -675,6 +930,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise; /** * Update function by its unique ID. @@ -684,7 +940,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -701,6 +957,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -728,6 +985,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise; update( paramsOrFirst: @@ -754,6 +1012,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -778,6 +1037,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise { let params: { @@ -803,6 +1063,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -833,6 +1094,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -858,6 +1120,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -883,6 +1146,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1223,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1234,66 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1425,66 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1588,54 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1882,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2092,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2246,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2359,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2663,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2784,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2315,7 +2980,45 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3091,45 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3284,36 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3441,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3533,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2862,7 +3670,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..b620ed0 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +169,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +243,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +317,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +393,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +468,35 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +547,30 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..bdc8ad3 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,35 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -335,7 +368,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -576,7 +627,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -893,7 +962,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1299,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1359,7 +1464,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +1628,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,7 +1790,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1792,7 +1951,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2026,25 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2181,36 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2289,36 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2230,7 +2483,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2394,7 +2666,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2556,7 +2847,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2717,7 +3027,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2837,7 +3166,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2954,7 +3302,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3063,7 +3430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3171,7 +3557,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3277,7 +3682,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3382,7 +3806,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3572,7 +4015,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3759,7 +4221,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3891,7 +4372,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4020,7 +4520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4184,7 +4703,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4345,7 +4883,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4509,7 +5066,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4670,7 +5246,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4860,7 +5455,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5047,7 +5661,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5293,7 +5926,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5538,7 +6190,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5778,7 +6449,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6017,7 +6707,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6149,7 +6858,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6278,7 +7006,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7157,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6539,7 +7305,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6671,7 +7456,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6800,7 +7604,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6932,7 +7755,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7061,7 +7903,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +7979,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8133,36 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7373,7 +8282,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8358,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7549,7 +8496,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8673,36 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8797,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8894,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..4c4e6b4 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,73 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -302,7 +373,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +448,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,7 +537,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -710,7 +927,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1109,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1215,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1310,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1498,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1590,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1343,7 +1739,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2000,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2089,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2239,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2355,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2485,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2601,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2077,7 +2694,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2842,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2263,7 +2992,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3152,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3238,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3308,35 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,7 +3452,35 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2714,7 +3597,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3691,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3764,50 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +3885,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..baa489e 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,73 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -302,7 +373,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +448,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,7 +537,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -710,7 +927,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1109,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1215,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1310,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1498,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1590,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1343,7 +1739,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2000,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2089,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2239,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2355,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2485,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2601,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2111,7 +2728,34 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2185,7 +2829,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2977,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2371,7 +3127,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3287,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3373,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,7 +3443,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2763,7 +3638,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3716,35 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,7 +3860,35 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3053,7 +4005,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4099,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4172,50 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4293,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..3cc7c93 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -349,7 +379,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -367,7 +397,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise; @@ -385,7 +415,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -404,7 +434,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise; @@ -422,7 +452,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -438,7 +468,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -455,7 +485,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -478,7 +508,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -495,7 +525,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,29 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1001,7 +1141,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1018,7 +1158,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -1035,7 +1175,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1053,7 +1193,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createPAR( @@ -1070,7 +1210,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1085,7 +1225,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, ] ): Promise { @@ -1101,7 +1241,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1122,7 +1262,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1138,7 +1278,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1362,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1456,31 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1538,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1669,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1494,7 +1683,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise; /** @@ -1508,7 +1697,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1523,7 +1712,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise; createToken( @@ -1537,7 +1726,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1738,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise { @@ -1562,7 +1751,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1769,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1782,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1844,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..72fd5e2 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,37 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +329,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,7 +406,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -377,7 +500,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +655,43 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +818,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +899,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1001,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1162,87 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1329,77 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1454,77 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1597,77 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1804,36 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1939,26 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2026,26 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1553,7 +2167,26 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..706df5a 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,73 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -302,7 +373,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +448,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,7 +537,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -710,7 +927,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1109,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1215,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1310,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1498,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1590,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1343,7 +1739,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2000,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2089,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2239,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2355,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2485,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2601,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2111,7 +2728,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2814,33 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2916,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,7 +3049,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2397,7 +3179,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3327,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2583,7 +3477,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3637,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3723,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,7 +3793,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2975,7 +3988,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4066,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,7 +4210,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3265,7 +4355,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4449,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4522,50 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4643,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..de5da33 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,33 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +174,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +327,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +489,23 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..5ad53f3 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +144,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise} @@ -81,7 +156,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise} @@ -144,7 +219,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -209,7 +354,36 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +466,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +536,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -452,7 +664,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +789,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +927,32 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1020,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1088,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1171,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1306,19 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1591,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1293,7 +1746,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1430,7 +1898,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1515,7 +2002,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1628,7 +2130,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1729,7 +2248,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1814,7 +2349,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1894,7 +2444,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1979,7 +2544,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2064,7 +2644,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2149,7 +2744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2229,7 +2839,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2330,7 +2955,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2415,7 +3056,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2495,7 +3151,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2580,7 +3251,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2660,7 +3346,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2745,7 +3446,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2846,7 +3562,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2947,7 +3679,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3048,7 +3796,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,7 +3943,25 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,7 +4046,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3365,7 +4162,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3478,7 +4291,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,7 +4393,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3652,7 +4497,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3765,7 +4625,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3854,7 +4731,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4024,7 +4916,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4155,7 +5067,25 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4240,7 +5170,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4325,7 +5270,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4410,7 +5370,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4495,7 +5470,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4596,7 +5586,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4681,7 +5687,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4766,7 +5787,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4851,7 +5887,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4936,7 +5987,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5025,7 +6091,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5114,7 +6195,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5199,7 +6295,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5284,7 +6395,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5369,7 +6495,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5454,7 +6595,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5539,7 +6695,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5624,7 +6795,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5725,7 +6911,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5810,7 +7012,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +7299,19 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +7320,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} */ @@ -6098,6 +7328,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise; /** * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. @@ -6105,6 +7336,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +7345,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +7374,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +7413,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +7424,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} */ @@ -6191,13 +7458,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +7475,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6224,18 +7504,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +7543,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +7554,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +7668,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +7781,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +7889,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +7997,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8105,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +8213,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +8330,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +8447,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +8664,19 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +8734,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +8862,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +8990,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +9118,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +9313,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +9484,201 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +9736,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7809,7 +9866,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +9994,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +10145,216 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +10467,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +10542,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +10670,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +10798,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,7 +10924,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8345,15 +11048,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +11136,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +11148,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +11166,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +11178,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +11188,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +11200,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +11316,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,7 +11467,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8801,7 +11720,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +11912,36 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9092,7 +12110,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +12210,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +12297,36 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +12437,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,7 +12511,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9512,7 +12635,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..4c19007 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,7 +111,22 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +194,41 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +286,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +401,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +562,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +675,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +752,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +882,30 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2456487 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,77 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +548,67 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +659,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +764,32 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +840,67 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1022,7 +1275,67 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1463,67 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1625,54 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1899,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2107,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2259,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2370,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2666,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2784,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2895,45 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + responseStatusCode: 0, + responseBody: '', + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3075,36 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3230,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3317,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2694,7 +3452,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..5f299b7 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,42 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -296,7 +332,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +412,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -554,7 +640,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +823,44 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1082,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1038,7 +1213,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..50b9eed 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,64 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -222,7 +284,54 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +350,41 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +452,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +531,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +605,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +711,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +859,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +931,54 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -822,7 +1107,54 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -950,7 +1282,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,7 +1395,45 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1105,7 +1531,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1632,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1327,7 +1809,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1941,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2027,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2110,50 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2257,55 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2474,45 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2582,45 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2028,7 +2762,45 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +2973,19 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2373,7 +3157,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2549,7 +3350,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2690,7 +3508,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2832,7 +3667,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2971,7 +3823,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3113,7 +3982,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3253,7 +4139,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3397,7 +4301,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3552,7 +4474,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3713,7 +4653,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3885,7 +4843,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4061,7 +5036,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4234,7 +5226,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4410,7 +5419,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4550,7 +5576,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4694,7 +5738,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4820,7 +5882,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4957,7 +6036,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5110,7 +6206,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5254,7 +6367,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5407,7 +6537,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5551,7 +6698,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5677,7 +6841,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5814,7 +6995,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5941,7 +7139,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6078,7 +7293,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6251,7 +7483,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6373,7 +7627,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6549,7 +7825,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6706,7 +8000,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6858,7 +8170,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7002,7 +8331,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7142,7 +8488,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7286,7 +8650,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7462,7 +8844,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7618,7 +9018,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,7 +9365,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8109,7 +9557,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9662,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +9893,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8561,7 +10076,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8670,7 +10202,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8781,7 +10340,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8899,7 +10485,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10618,34 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10763,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9277,7 +10934,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9431,7 +11105,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9683,7 +11374,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9828,6 +11536,23 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..931588e 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +204,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +277,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +367,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +516,37 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +636,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +730,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -696,7 +845,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1039,43 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -885,6 +1090,7 @@ export class Teams { * * @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. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.email - Email of the new team member. * @param {string} params.userId - ID of the user to be added to a team. * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -896,6 +1102,7 @@ export class Teams { createMembership(params: { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -914,6 +1121,7 @@ export class Teams { * * @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. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} email - Email of the new team member. * @param {string} userId - ID of the user to be added to a team. * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -926,6 +1134,7 @@ export class Teams { createMembership( teamId: string, roles: string[], + membershipId?: string, email?: string, userId?: string, phone?: string, @@ -937,6 +1146,7 @@ export class Teams { | { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -944,11 +1154,20 @@ export class Teams { name?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise { let params: { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -964,6 +1183,7 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; roles: string[]; + membershipId?: string; email?: string; userId?: string; phone?: string; @@ -974,16 +1194,18 @@ export class Teams { params = { teamId: paramsOrFirst as string, roles: rest[0] as string[], - email: rest[1] as string, - userId: rest[2] as string, - phone: rest[3] as string, - url: rest[4] as string, - name: rest[5] as string, + membershipId: rest[1] as string, + email: rest[2] as string, + userId: rest[3] as string, + phone: rest[4] as string, + url: rest[5] as string, + name: rest[6] as string, }; } const teamId = params.teamId; const roles = params.roles; + const membershipId = params.membershipId; const email = params.email; const userId = params.userId; const phone = params.phone; @@ -1000,6 +1222,9 @@ export class Teams { encodeURIComponent(String(teamId)), ); const apiPayload: Payload = {}; + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } if (typeof email !== 'undefined') { apiPayload['email'] = email; } @@ -1026,7 +1251,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1351,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1468,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1685,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..beab21b 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,35 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -191,7 +224,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +297,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -316,7 +385,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..6652ee1 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,7 +94,59 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +263,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +417,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +571,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +692,39 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +892,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1046,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1299,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1509,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1680,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1779,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1947,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2070,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2194,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2287,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2431,43 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2542,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2658,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2912,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +2982,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3051,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3123,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3190,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3259,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3327,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3396,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3464,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3550,408 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @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. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise; + listPasskeys( + 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; + }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4030,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4149,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4386,57 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4494,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4729,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4852,36 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5023,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5110,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5245,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5414,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5513,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5637,48 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..31db5a2 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,64 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +268,54 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +334,41 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +436,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +515,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +589,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +695,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +843,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +915,54 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1094,54 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1299,55 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1501,45 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1615,45 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1345,7 +1801,45 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2048,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2244,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2378,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2524,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2675,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2814,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +2979,34 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3135,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3321,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3507,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3749,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +3944,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4052,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3444,7 +4235,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4395,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4481,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4564,49 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..ae34e19 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2414 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + string?, + string?, + string?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + limit?: number, + interval?: number, + key?: string, + maxBucketSize?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + number?, + number?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + limit?: number; + interval?: number; + key?: string; + maxBucketSize?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + limit: rest[4] as number, + interval: rest[5] as number, + key: rest[6] as string, + maxBucketSize: rest[7] as number, + priority: rest[8] as number, + enabled: rest[9] as boolean, + conditions: rest[10] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + string?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.name - Rule name. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to disable the rule. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} resourceId - Resource identifier. Required for functions and sites. + * @param {string} name - Rule name. + * @param {string} description - Optional description for the rule. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to disable the rule. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string, + resourceId?: string, + name?: string, + description?: string, + location?: string, + statusCode?: number, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + string?, + string?, + number?, + number?, + boolean?, + string[]?, + ] + ): Promise { + let params: { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string; + resourceId?: string; + name?: string; + description?: string; + location?: string; + statusCode?: number; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + resourceId: rest[1] as string, + name: rest[2] as string, + description: rest[3] as string, + location: rest[4] as string, + statusCode: rest[5] as number, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..8d41212 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,41 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,8 +121,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise} @@ -108,8 +147,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise} @@ -253,7 +292,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +371,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +407,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise} */ @@ -344,8 +431,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -478,7 +565,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,6 +713,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..7c83d4c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -593,6 +593,96 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '', + {}, + ); + + // 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', @@ -1205,6 +1295,39 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + '\\$id': 'bb8ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('', {}); + + // 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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..6e8adec 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -615,16 +615,12 @@ describe('DocumentsDB', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..37fb788 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -31,16 +31,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -105,16 +101,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -166,16 +158,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -447,16 +435,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -508,16 +492,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -591,16 +571,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -652,16 +628,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -717,16 +689,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -832,14 +800,9 @@ describe('Mongo', () => { '\\$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)); @@ -855,14 +818,9 @@ describe('Mongo', () => { '\\$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)); @@ -905,16 +863,12 @@ describe('Mongo', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..1c559c8 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -31,16 +31,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -105,16 +101,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -166,16 +158,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -447,16 +435,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -508,16 +492,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -608,16 +588,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -669,16 +645,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -734,16 +706,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -891,14 +859,9 @@ describe('Mysql', () => { '\\$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)); @@ -914,14 +877,9 @@ describe('Mysql', () => { '\\$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)); @@ -964,16 +922,12 @@ describe('Mysql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..b441acf 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -57,13 +50,6 @@ describe('Organization', () => { 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', diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..6109f80 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -31,16 +31,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -105,16 +101,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -166,16 +158,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -450,16 +438,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -511,16 +495,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -628,16 +608,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -692,16 +668,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -756,16 +728,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -817,16 +785,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -882,16 +846,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1042,14 +1002,9 @@ describe('Postgresql', () => { '\\$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)); @@ -1065,14 +1020,9 @@ describe('Postgresql', () => { '\\$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)); @@ -1115,16 +1065,12 @@ describe('Postgresql', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..f51f0b0 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -1164,6 +1164,7 @@ describe('Project', () => { name: 'My Web App', type: 'web', applicationId: 'com.company.appname', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1185,6 +1186,7 @@ describe('Project', () => { name: 'My Web App', type: 'web', applicationId: 'com.company.appname', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1628,6 +1630,43 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy(''); + + // 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', @@ -1776,6 +1815,43 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + '\\$id': '5e5ea5c16897e', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { '\\$id': 'password-dictionary', @@ -1981,7 +2057,8 @@ describe('Project', () => { test('test method getPolicy()', async () => { const data = { '\\$id': 'password-dictionary', - enabled: true, + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..252d406 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -196,16 +196,12 @@ describe('TablesDB', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..169c776 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -675,6 +675,65 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('', ''); + + // 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', diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..0d84ead 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -587,16 +587,12 @@ describe('VectorsDB', () => { '\\$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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..5c693f8 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '', + 'api', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '', + 'api', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('', 'api', ''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '', + 'api', + '', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '', + 'api', + '', + '', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + '\\$id': 'wafRule1', + '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule(''); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); +}); From 9ecbd2bed70feb9a91a2df64516a19d8603dfcb7 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 17:26:21 +0100 Subject: [PATCH 2/7] revert: undo the superseded SDK update on dev --- CHANGELOG.md | 56 +- README.md | 4 +- .../examples/account/create-o-auth-2-token.md | 1 - docs/examples/account/create-passkey-token.md | 12 - docs/examples/account/create-passkey.md | 15 - docs/examples/account/delete-passkey.md | 14 - docs/examples/account/get-passkey.md | 14 - docs/examples/account/list-passkeys.md | 15 - docs/examples/account/update-passkey-token.md | 15 - .../account/update-passkey-verification.md | 15 - docs/examples/account/update-passkey.md | 15 - docs/examples/functions/create.md | 1 - docs/examples/functions/update.md | 1 - docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../project/create-android-platform.md | 1 - .../project/update-android-platform.md | 1 - .../examples/project/update-passkey-policy.md | 14 - .../update-password-rotation-policy.md | 15 - docs/examples/teams/create-membership.md | 1 - docs/examples/users/delete-passkey.md | 15 - docs/examples/users/get-passkey.md | 15 - docs/examples/users/list-passkeys.md | 16 - docs/examples/users/update-passkey.md | 16 - docs/examples/waf/create-bypass-rule.md | 21 - docs/examples/waf/create-challenge-rule.md | 24 - docs/examples/waf/create-deny-rule.md | 21 - docs/examples/waf/create-rate-limit-rule.md | 26 - docs/examples/waf/create-redirect-rule.md | 23 - docs/examples/waf/delete-rule.md | 14 - docs/examples/waf/get-rule.md | 14 - docs/examples/waf/list-rules.md | 16 - docs/examples/waf/update-bypass-rule.md | 21 - docs/examples/waf/update-challenge-rule.md | 24 - docs/examples/waf/update-deny-rule.md | 21 - docs/examples/waf/update-rate-limit-rule.md | 25 - docs/examples/waf/update-redirect-rule.md | 23 - package-lock.json | 4 +- package.json | 2 +- src/client.ts | 50 +- src/enums/project-auth-method-id.ts | 1 - src/enums/project-key-scopes.ts | 2 - src/enums/project-policy-id.ts | 2 - src/enums/waf-rule-action.ts | 7 - src/index.ts | 2 - src/models.ts | 567 +-- src/services/account.ts | 2215 +---------- src/services/activities.ts | 101 +- src/services/advisor.ts | 221 +- src/services/apps.ts | 621 +-- src/services/avatars.ts | 1 - src/services/backups.ts | 241 +- src/services/databases.ts | 1536 +------- src/services/documents-db.ts | 1016 +---- src/services/domains.ts | 1376 +------ src/services/embeddings.ts | 34 +- src/services/functions.ts | 875 +---- src/services/locale.ts | 204 +- src/services/messaging.ts | 1139 +----- src/services/mongo.ts | 1076 +----- src/services/mysql.ts | 1151 +----- src/services/oauth-2.ts | 321 +- src/services/organization.ts | 671 +--- src/services/postgresql.ts | 1295 +------ src/services/presences.ts | 89 +- src/services/project.ts | 3372 +---------------- src/services/proxy.ts | 216 +- src/services/sites.ts | 815 +--- src/services/storage.ts | 216 +- src/services/tables-db.ts | 1873 +-------- src/services/teams.ts | 369 +- src/services/tokens.ts | 97 +- src/services/users.ts | 1731 +-------- src/services/vectors-db.ts | 1011 +---- src/services/waf.ts | 2414 ------------ src/services/webhooks.ts | 163 +- test/services/account.test.js | 123 - test/services/documents-d-b.test.js | 4 + test/services/mongo.test.js | 46 + test/services/mysql.test.js | 46 + test/services/organization.test.js | 14 + test/services/postgresql.test.js | 54 + test/services/project.test.js | 79 +- test/services/tables-d-b.test.js | 4 + test/services/users.test.js | 59 - test/services/vectors-d-b.test.js | 4 + test/services/waf.test.js | 354 -- 90 files changed, 1068 insertions(+), 27371 deletions(-) delete mode 100644 docs/examples/account/create-passkey-token.md delete mode 100644 docs/examples/account/create-passkey.md delete mode 100644 docs/examples/account/delete-passkey.md delete mode 100644 docs/examples/account/get-passkey.md delete mode 100644 docs/examples/account/list-passkeys.md delete mode 100644 docs/examples/account/update-passkey-token.md delete mode 100644 docs/examples/account/update-passkey-verification.md delete mode 100644 docs/examples/account/update-passkey.md delete mode 100644 docs/examples/project/update-passkey-policy.md delete mode 100644 docs/examples/project/update-password-rotation-policy.md delete mode 100644 docs/examples/users/delete-passkey.md delete mode 100644 docs/examples/users/get-passkey.md delete mode 100644 docs/examples/users/list-passkeys.md delete mode 100644 docs/examples/users/update-passkey.md delete mode 100644 docs/examples/waf/create-bypass-rule.md delete mode 100644 docs/examples/waf/create-challenge-rule.md delete mode 100644 docs/examples/waf/create-deny-rule.md delete mode 100644 docs/examples/waf/create-rate-limit-rule.md delete mode 100644 docs/examples/waf/create-redirect-rule.md delete mode 100644 docs/examples/waf/delete-rule.md delete mode 100644 docs/examples/waf/get-rule.md delete mode 100644 docs/examples/waf/list-rules.md delete mode 100644 docs/examples/waf/update-bypass-rule.md delete mode 100644 docs/examples/waf/update-challenge-rule.md delete mode 100644 docs/examples/waf/update-deny-rule.md delete mode 100644 docs/examples/waf/update-rate-limit-rule.md delete mode 100644 docs/examples/waf/update-redirect-rule.md delete mode 100644 src/enums/waf-rule-action.ts delete mode 100644 src/services/waf.ts delete mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 2610013..f79a0ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,54 +1,34 @@ # Change Log +## 30.0.0-rc.2 + +* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) +* Added: `Topic` and `ResolvedTopic` exports +* Added: `Models.Account` and `Models.OAuth2Webflow` types +* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums +* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods +* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions +* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file +* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object + ## 30.0.0 * Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey` -* Breaking: `OrganizationKeyScopes` enum removed +* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed * Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed * Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList.pricing` removed; rates live on `DedicatedDatabaseSpecification` +* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` * Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Breaking: `resource` on `oauth2` authorize, PAR, device and token methods is now `string[]` -* Breaking: `BackupRestoration.options` is now an object -* Breaking: deprecated positional arguments shift on `teams.createMembership`, `messaging` email/push/SMS and `project.updateOAuth2*` -* Added: `account` passkey methods: `createPasskey`, `updatePasskeyVerification`, `createPasskeyToken`, `updatePasskeyToken` -* Added: `account.listPasskeys`, `getPasskey`, `updatePasskey` and `deletePasskey` -* Added: `users.listPasskeys`, `getPasskey`, `updatePasskey` and `deletePasskey` -* Added: `project.updatePasskeyPolicy` and `passkey` policy and auth method IDs -* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge`, `PolicyPasskey` and `TokenSecret` models -* Added: `fingerprints` on Android platform create and update, and on `PlatformAndroid` -* Added: `waf` service for bypass, challenge, deny, rate limit and redirect rules +* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model * Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `oauth2.introspect` returning the `Oauth2Introspection` model * Added: `account.createIdTokenSession` and email verification and recovery OTP methods * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy`, `PolicyPasswordPwned` and `User.passwordPwned` -* Added: Kakao, TikTok and Webflow OAuth2 providers, and `prompt` enums per provider +* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` +* Added: Kakao and TikTok OAuth2 providers * Added: native client IDs on the Apple and Google OAuth2 providers -* Added: `avatars.updatePhoto` and `avatars.deletePhoto` -* Added: `membershipId` on `teams.createMembership` -* Added: reply-to on email messages, `channelId` on push, `qos` and `expiry` on topics -* Added: optional `total` on locale and list endpoints, `duration` on email-password sessions -* Added: `Topic`, `ResolvedTopic` and `Models.Account` exports -* Added: `analytics.read`, `analytics.write`, `avatars.write` and `dedicatedDatabases.execute` key scopes -* Added: storage resize fields on `DedicatedDatabase`, `firstAccessedAt` and `mcpAccessedAt` on `Project` +* Added: reply-to on email messages, `qos` and `expiry` on topics * Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Added: `project.updatePasswordRotationPolicy` and the `PolicyPasswordRotation` model -* Fixed: response models fill missing fields from spec defaults instead of throwing -* Fixed: object values in multipart requests are sent as JSON -* Updated: `chunkedUpload` supports a `text` response type and works without a file -* Updated: several `Organization`, `UsageBillingPlan` and dedicated database model fields are now optional -* Updated: requests send `X-Appwrite-Response-Format` `2.4.0` - -## 29.2.0 - -* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes -* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model - -## 29.1.0 - -* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs +* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` ## 29.0.0 diff --git a/README.md b/README.md index 6374da1..900e4e2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.4.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.4.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index fa54473..40e1d1f 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,6 +13,5 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional - state: '', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md deleted file mode 100644 index cf4a5c7..0000000 --- a/docs/examples/account/create-passkey-token.md +++ /dev/null @@ -1,12 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.createPasskeyToken(); -``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md deleted file mode 100644 index 50bdf74..0000000 --- a/docs/examples/account/create-passkey.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.createPasskey({ - passkeyId: '', // optional - name: '', // optional -}); -``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md deleted file mode 100644 index d19b717..0000000 --- a/docs/examples/account/delete-passkey.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.deletePasskey({ - passkeyId: '', -}); -``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md deleted file mode 100644 index 3a125d0..0000000 --- a/docs/examples/account/get-passkey.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.getPasskey({ - passkeyId: '', -}); -``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md deleted file mode 100644 index 403da40..0000000 --- a/docs/examples/account/list-passkeys.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.listPasskeys({ - queries: [], // optional - total: false, // optional -}); -``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md deleted file mode 100644 index 1bdc685..0000000 --- a/docs/examples/account/update-passkey-token.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.updatePasskeyToken({ - challengeId: '', - credential: {}, -}); -``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md deleted file mode 100644 index d3294a1..0000000 --- a/docs/examples/account/update-passkey-verification.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.updatePasskeyVerification({ - passkeyId: '', - credential: {}, -}); -``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md deleted file mode 100644 index f296b3e..0000000 --- a/docs/examples/account/update-passkey.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setSession(''); // The user session to authenticate with - -const account = new sdk.Account(client); - -const result = await account.updatePasskey({ - passkeyId: '', - name: '', -}); -``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index c20e342..7d6e855 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,6 +31,5 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional - interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 78a1de6..2f299f2 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,6 +31,5 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional - interval: 0, // optional }); ``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 32320e9..003c717 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: [], // optional + resource: '', // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index 384e3bf..fe529c6 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: [], // optional + resource: '', // optional audience: '', // optional requestUri: '', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 4215069..e49bef1 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: [], // optional + resource: '', // optional audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 575b70e..b579484 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: [], // optional + resource: '', // optional audience: '', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index cb9ca65..ea081d1 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: [], // optional + resource: '', // optional audience: '', // optional }); ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 8e0d6f7..083eee1 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,6 +12,5 @@ const result = await project.createAndroidPlatform({ platformId: '', name: '', applicationId: '', - fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 83d4d65..ad0d3d2 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,6 +12,5 @@ const result = await project.updateAndroidPlatform({ platformId: '', name: '', applicationId: '', - fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md deleted file mode 100644 index c289240..0000000 --- a/docs/examples/project/update-passkey-policy.md +++ /dev/null @@ -1,14 +0,0 @@ -```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.updatePasskeyPolicy({ - rpId: '', -}); -``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md deleted file mode 100644 index b6d281e..0000000 --- a/docs/examples/project/update-password-rotation-policy.md +++ /dev/null @@ -1,15 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const project = new sdk.Project(client); - -const result = await project.updatePasswordRotationPolicy({ - enabled: false, // optional - maxAge: 86400, // optional -}); -``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c859bec..47773fb 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -11,7 +11,6 @@ const teams = new sdk.Teams(client); const result = await teams.createMembership({ teamId: '', roles: ['editor'], - membershipId: '', // optional email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md deleted file mode 100644 index 0a8b24b..0000000 --- a/docs/examples/users/delete-passkey.md +++ /dev/null @@ -1,15 +0,0 @@ -```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 users = new sdk.Users(client); - -const result = await users.deletePasskey({ - userId: '', - passkeyId: '', -}); -``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md deleted file mode 100644 index f4f8ac7..0000000 --- a/docs/examples/users/get-passkey.md +++ /dev/null @@ -1,15 +0,0 @@ -```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 users = new sdk.Users(client); - -const result = await users.getPasskey({ - userId: '', - passkeyId: '', -}); -``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md deleted file mode 100644 index cd08eeb..0000000 --- a/docs/examples/users/list-passkeys.md +++ /dev/null @@ -1,16 +0,0 @@ -```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 users = new sdk.Users(client); - -const result = await users.listPasskeys({ - userId: '', - queries: [], // optional - total: false, // optional -}); -``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md deleted file mode 100644 index b6572ba..0000000 --- a/docs/examples/users/update-passkey.md +++ /dev/null @@ -1,16 +0,0 @@ -```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 users = new sdk.Users(client); - -const result = await users.updatePasskey({ - userId: '', - passkeyId: '', - name: '', -}); -``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md deleted file mode 100644 index 36ac236..0000000 --- a/docs/examples/waf/create-bypass-rule.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.createBypassRule({ - ruleId: '', - resourceType: 'api', - name: '', - resourceId: '', // optional - description: '', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md deleted file mode 100644 index 8a52e55..0000000 --- a/docs/examples/waf/create-challenge-rule.md +++ /dev/null @@ -1,24 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.createChallengeRule({ - ruleId: '', - resourceType: 'api', - name: '', - resourceId: '', // optional - description: '', // optional - challengeType: 'compute', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional - difficulty: 1, // optional - ttl: 900, // optional -}); -``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md deleted file mode 100644 index 2fd6fdc..0000000 --- a/docs/examples/waf/create-deny-rule.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.createDenyRule({ - ruleId: '', - resourceType: 'api', - name: '', - resourceId: '', // optional - description: '', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md deleted file mode 100644 index d40cd0b..0000000 --- a/docs/examples/waf/create-rate-limit-rule.md +++ /dev/null @@ -1,26 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.createRateLimitRule({ - ruleId: '', - resourceType: 'api', - name: '', - limit: 1, - interval: 1, - resourceId: '', // optional - description: '', // optional - key: 'ip', // optional - strategy: 'fixedWindow', // optional - maxBucketSize: 1, // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md deleted file mode 100644 index d606bc9..0000000 --- a/docs/examples/waf/create-redirect-rule.md +++ /dev/null @@ -1,23 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.createRedirectRule({ - ruleId: '', - resourceType: 'api', - name: '', - location: '', - statusCode: 300, - resourceId: '', // optional - description: '', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md deleted file mode 100644 index 3b08063..0000000 --- a/docs/examples/waf/delete-rule.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.deleteRule({ - ruleId: '', -}); -``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md deleted file mode 100644 index 5d4bbe1..0000000 --- a/docs/examples/waf/get-rule.md +++ /dev/null @@ -1,14 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.getRule({ - ruleId: '', -}); -``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md deleted file mode 100644 index eef8e17..0000000 --- a/docs/examples/waf/list-rules.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.listRules({ - queries: [], // optional - search: '', // optional - total: false, // optional -}); -``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md deleted file mode 100644 index 9fa71c1..0000000 --- a/docs/examples/waf/update-bypass-rule.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.updateBypassRule({ - ruleId: '', - resourceType: 'api', // optional - resourceId: '', // optional - name: '', // optional - description: '', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md deleted file mode 100644 index a5f85ba..0000000 --- a/docs/examples/waf/update-challenge-rule.md +++ /dev/null @@ -1,24 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.updateChallengeRule({ - ruleId: '', - resourceType: 'api', // optional - resourceId: '', // optional - name: '', // optional - description: '', // optional - challengeType: 'compute', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional - difficulty: 1, // optional - ttl: 900, // optional -}); -``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md deleted file mode 100644 index 2764b4c..0000000 --- a/docs/examples/waf/update-deny-rule.md +++ /dev/null @@ -1,21 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.updateDenyRule({ - ruleId: '', - resourceType: 'api', // optional - resourceId: '', // optional - name: '', // optional - description: '', // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md deleted file mode 100644 index f7810bd..0000000 --- a/docs/examples/waf/update-rate-limit-rule.md +++ /dev/null @@ -1,25 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.updateRateLimitRule({ - ruleId: '', - resourceType: 'api', // optional - resourceId: '', // optional - name: '', // optional - description: '', // optional - limit: 1, // optional - interval: 1, // optional - key: 'ip', // optional - maxBucketSize: 1, // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md deleted file mode 100644 index 7355421..0000000 --- a/docs/examples/waf/update-redirect-rule.md +++ /dev/null @@ -1,23 +0,0 @@ -```javascript -const sdk = require('node-appwrite'); - -const client = new sdk.Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject('') // Your project ID - .setKey(''); // Your secret API key - -const waf = new sdk.Waf(client); - -const result = await waf.updateRedirectRule({ - ruleId: '', - resourceType: 'api', // optional - resourceId: '', // optional - name: '', // optional - description: '', // optional - location: '', // optional - statusCode: 300, // optional - priority: -100000, // optional - enabled: false, // optional - conditions: [], // optional -}); -``` diff --git a/package-lock.json b/package-lock.json index b36b64e..686fc2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0", + "version": "30.0.0-rc.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0", + "version": "30.0.0-rc.2", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index 9272cdc..e69605d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0", + "version": "30.0.0-rc.2", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 2eefc67..393e2b4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -44,50 +44,6 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; -type DefaultsShape = string | { items: DefaultsShape }; - -type DefaultsModel = { - defaults?: Record; - properties?: Record; -}; - -type Defaults = { - root: DefaultsShape; - models: Record; -}; - -export function applyDefaults(value: T, tree: Defaults): T { - return fillDefaults(value, tree.root, tree.models) as T; -} - -function fillDefaults( - value: unknown, - shape: DefaultsShape, - models: Record, -): unknown { - if (typeof shape !== 'string') { - if (!Array.isArray(value)) { - return value; - } - const items = shape.items; - return value.map((item) => fillDefaults(item, items, models)); - } - const model = models[shape]; - if (!model || typeof value !== 'object' || value === null) { - return value; - } - if (Array.isArray(value)) { - return value; - } - const result: Record = { ...model.defaults, ...value }; - for (const [key, child] of Object.entries(model.properties ?? {})) { - if (key in result) { - result[key] = fillDefaults(result[key], child, models); - } - } - return result; -} - type Payload = { [key: string]: any; }; @@ -124,7 +80,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0'; + let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -185,9 +141,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0', + 'x-sdk-version': '30.0.0-rc.2', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.4.0', + 'X-Appwrite-Response-Format': '2.3.0', }; /** diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 34504b4..367ed14 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,5 +6,4 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', - Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 3cb8cc4..48ab459 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,6 +122,4 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', - AnalyticsRead = 'analytics.read', - AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index 67fc5fe..d323094 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,7 +4,6 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', - Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -16,5 +15,4 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', - Passkey = 'passkey', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts deleted file mode 100644 index 38534a9..0000000 --- a/src/enums/waf-rule-action.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum WafRuleAction { - Bypass = 'bypass', - Deny = 'deny', - Challenge = 'challenge', - RateLimit = 'rateLimit', - Redirect = 'redirect', -} diff --git a/src/index.ts b/src/index.ts index 35f0b73..3042486 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,6 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; -export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; @@ -120,4 +119,3 @@ export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; -export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 6a00134..1fac7bc 100644 --- a/src/models.ts +++ b/src/models.ts @@ -25,7 +25,6 @@ import { ProxyRuleStatus } from './enums/proxy-rule-status'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; -import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -504,7 +503,6 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned - | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -516,7 +514,6 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail - | Models.PolicyPasskey )[]; }; @@ -4204,10 +4201,6 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; - /** - * Minutes between scheduled executions. 0 when the function has no interval. - */ - interval?: number; /** * Function execution timeout in seconds. */ @@ -6258,24 +6251,6 @@ export namespace Models { users: boolean; }; - /** - * Policy Password Rotation - */ - export type PolicyPasswordRotation = { - /** - * Policy ID. - */ - $id: string; - /** - * Whether expired passwords require a reset before email/password sign-in. - */ - enabled: boolean; - /** - * Maximum password age in seconds. - */ - maxAge: number; - }; - /** * Policy Session Alert */ @@ -6406,24 +6381,6 @@ export namespace Models { custom: boolean; }; - /** - * Policy Passkey - */ - export type PolicyPasskey = { - /** - * Policy ID. - */ - $id: string; - /** - * Relying party ID passkeys are bound to. Empty until configured. - */ - rpId: string; - /** - * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. - */ - origins: string[]; - }; - /** * Policy Deny Aliased Email */ @@ -6568,10 +6525,6 @@ export namespace Models { * Android application ID. */ applicationId: string; - /** - * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. - */ - fingerprints: string[]; }; /** @@ -6978,102 +6931,6 @@ export namespace Models { code: string; }; - /** - * Token Secret - */ - export type TokenSecret = { - /** - * Token ID. - */ - $id: string; - /** - * Token creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * User ID. - */ - userId: string; - /** - * Token secret key. Exchange it for a session with the create session endpoint. - */ - secret: string; - /** - * Token expiration date in ISO 8601 format. - */ - expire: string; - /** - * 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; - }; - - /** - * Passkey - */ - export type Passkey = { - /** - * Passkey ID. - */ - $id: string; - /** - * Passkey creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Passkey update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Passkey name. - */ - name: string; - /** - * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. - */ - accessedAt: string; - }; - - /** - * Passkey Challenge - */ - export type PasskeyChallenge = { - /** - * Challenge ID. When signing in, pass it back with the credential to receive a token. - */ - $id: string; - /** - * Challenge creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * ID of the passkey being registered. Empty for sign-in challenges. - */ - passkeyId: string; - /** - * Challenge expiration date in ISO 8601 format. - */ - expire: string; - /** - * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. - */ - publicKey: object; - }; - - /** - * Passkeys List - */ - export type PasskeyList = { - /** - * Total number of passkeys that matched your query. - */ - total: number; - /** - * List of passkeys. - */ - passkeys: Passkey[]; - }; - /** * MFA Recovery Codes */ @@ -8164,10 +8021,6 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; - /** - * Shortest function schedule interval allowed, in minutes. 0 allows every interval. - */ - functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8413,7 +8266,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port?: number; + port: number; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8555,11 +8408,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api?: string; + api: string; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine?: string; + engine: string; /** * Database engine version. */ @@ -8579,7 +8432,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort?: number; + connectionPort: number; /** * Database username for connections. */ @@ -8591,7 +8444,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration?: number; + credentialGeneration: number; /** * Full database connection string (URI format). */ @@ -8805,7 +8658,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId?: string; + sourceDatabaseId: string; /** * Project ID. */ @@ -8813,7 +8666,7 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId?: string; + backupId: string; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ @@ -8825,15 +8678,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime?: string; + targetTime: string; /** * Restoration start time in ISO 8601 format. */ - startedAt?: string; + startedAt: string; /** * Restoration completion time in ISO 8601 format. */ - completedAt?: string; + completedAt: string; /** * Error message if restoration failed. */ @@ -9295,15 +9148,15 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate?: string; + billingStartDate: string; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate?: string; + billingCurrentInvoiceDate: string; /** * Next invoice cycle start date. */ - billingNextInvoiceDate?: string; + billingNextInvoiceDate: string; /** * Start date of trial. */ @@ -9311,19 +9164,19 @@ export namespace Models { /** * Number of trial days. */ - billingTrialDays?: number; + billingTrialDays: number; /** * Current active aggregation id. */ - billingAggregationId?: string; + billingAggregationId: string; /** * Current active aggregation id. */ - billingInvoiceId?: string; + billingInvoiceId: string; /** * Default payment method. */ - paymentMethodId?: string; + paymentMethodId: string; /** * Default payment method. */ @@ -9769,11 +9622,11 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth?: AdditionalResource; + bandwidth: AdditionalResource; /** * Executions additional resources */ - executions?: AdditionalResource; + executions: AdditionalResource; /** * Member additional resources */ @@ -9781,11 +9634,11 @@ export namespace Models { /** * Realtime additional resources */ - realtime?: AdditionalResource; + realtime: AdditionalResource; /** * Realtime messages additional resources */ - realtimeMessages?: AdditionalResource; + realtimeMessages: AdditionalResource; /** * Realtime bandwidth additional resources */ @@ -9793,19 +9646,19 @@ export namespace Models { /** * Storage additional resources */ - storage?: AdditionalResource; + storage: AdditionalResource; /** * User additional resources */ - users?: AdditionalResource; + users: AdditionalResource; /** * GBHour additional resources */ - GBHours?: AdditionalResource; + GBHours: AdditionalResource; /** * Image transformation additional resources */ - imageTransformations?: AdditionalResource; + imageTransformations: AdditionalResource; /** * Credits additional resources */ @@ -10436,376 +10289,6 @@ export namespace Models { expire: string; }; - /** - * WafRuleBypass - */ - export type WafRuleBypass = { - /** - * Rule ID. - */ - $id: string; - /** - * WAF rule creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * WAF rule last update time in ISO 8601 format. - */ - $updatedAt: string; - /** - * Human friendly rule name. - */ - name: string; - /** - * Optional description for the rule. - */ - description: string; - /** - * Team ID. - */ - teamId: string; - /** - * Project ID. - */ - projectId: string; - /** - * Resource type the rule is scoped to. - */ - resourceType: string; - /** - * Resource identifier. Empty for API-wide rules. - */ - resourceId: string; - /** - * Action performed when the rule matches. - */ - action: WafRuleAction; - /** - * Evaluation priority. Lower values execute earlier. - */ - priority: number; - /** - * Whether the rule is active. - */ - enabled: boolean; - /** - * List of conditions evaluated for this rule. - */ - conditions: Record[]; - /** - * Action specific configuration. - */ - config: object; - }; - - /** - * WafRuleDeny - */ - export type WafRuleDeny = { - /** - * Rule ID. - */ - $id: string; - /** - * WAF rule creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * WAF rule last update time in ISO 8601 format. - */ - $updatedAt: string; - /** - * Human friendly rule name. - */ - name: string; - /** - * Optional description for the rule. - */ - description: string; - /** - * Team ID. - */ - teamId: string; - /** - * Project ID. - */ - projectId: string; - /** - * Resource type the rule is scoped to. - */ - resourceType: string; - /** - * Resource identifier. Empty for API-wide rules. - */ - resourceId: string; - /** - * Action performed when the rule matches. - */ - action: WafRuleAction; - /** - * Evaluation priority. Lower values execute earlier. - */ - priority: number; - /** - * Whether the rule is active. - */ - enabled: boolean; - /** - * List of conditions evaluated for this rule. - */ - conditions: Record[]; - /** - * Action specific configuration. - */ - config: object; - }; - - /** - * WafRuleChallenge - */ - export type WafRuleChallenge = { - /** - * Rule ID. - */ - $id: string; - /** - * WAF rule creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * WAF rule last update time in ISO 8601 format. - */ - $updatedAt: string; - /** - * Human friendly rule name. - */ - name: string; - /** - * Optional description for the rule. - */ - description: string; - /** - * Team ID. - */ - teamId: string; - /** - * Project ID. - */ - projectId: string; - /** - * Resource type the rule is scoped to. - */ - resourceType: string; - /** - * Resource identifier. Empty for API-wide rules. - */ - resourceId: string; - /** - * Action performed when the rule matches. - */ - action: WafRuleAction; - /** - * Evaluation priority. Lower values execute earlier. - */ - priority: number; - /** - * Whether the rule is active. - */ - enabled: boolean; - /** - * List of conditions evaluated for this rule. - */ - conditions: Record[]; - /** - * Action specific configuration. - */ - config: object; - /** - * Challenge type enforced when the rule matches. - */ - challengeType: string; - /** - * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. - */ - difficulty: number; - /** - * Seconds a visitor stays cleared after passing the challenge before being challenged again. - */ - ttl: number; - }; - - /** - * WafRuleRateLimit - */ - export type WafRuleRateLimit = { - /** - * Rule ID. - */ - $id: string; - /** - * WAF rule creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * WAF rule last update time in ISO 8601 format. - */ - $updatedAt: string; - /** - * Human friendly rule name. - */ - name: string; - /** - * Optional description for the rule. - */ - description: string; - /** - * Team ID. - */ - teamId: string; - /** - * Project ID. - */ - projectId: string; - /** - * Resource type the rule is scoped to. - */ - resourceType: string; - /** - * Resource identifier. Empty for API-wide rules. - */ - resourceId: string; - /** - * Action performed when the rule matches. - */ - action: WafRuleAction; - /** - * Evaluation priority. Lower values execute earlier. - */ - priority: number; - /** - * Whether the rule is active. - */ - enabled: boolean; - /** - * List of conditions evaluated for this rule. - */ - conditions: Record[]; - /** - * Action specific configuration. - */ - config: object; - /** - * Maximum number of matching requests allowed for the given interval. - */ - limit: number; - /** - * Interval in seconds for the rate limit window. - */ - interval: number; - /** - * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. - */ - key: string; - /** - * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. - */ - strategy: string; - /** - * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. - */ - maxBucketSize: number; - }; - - /** - * WafRuleRedirect - */ - export type WafRuleRedirect = { - /** - * Rule ID. - */ - $id: string; - /** - * WAF rule creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * WAF rule last update time in ISO 8601 format. - */ - $updatedAt: string; - /** - * Human friendly rule name. - */ - name: string; - /** - * Optional description for the rule. - */ - description: string; - /** - * Team ID. - */ - teamId: string; - /** - * Project ID. - */ - projectId: string; - /** - * Resource type the rule is scoped to. - */ - resourceType: string; - /** - * Resource identifier. Empty for API-wide rules. - */ - resourceId: string; - /** - * Action performed when the rule matches. - */ - action: WafRuleAction; - /** - * Evaluation priority. Lower values execute earlier. - */ - priority: number; - /** - * Whether the rule is active. - */ - enabled: boolean; - /** - * List of conditions evaluated for this rule. - */ - conditions: Record[]; - /** - * Action specific configuration. - */ - config: object; - /** - * Target location for the redirect. - */ - location: string; - /** - * HTTP status code used for the redirect. - */ - statusCode: number; - }; - - /** - * WAF rule list - */ - export type WafRuleList = { - /** - * Total number of rules that matched your query. - */ - total: number; - /** - * List of rules. - */ - rules: ( - | Models.WafRuleBypass - | Models.WafRuleDeny - | Models.WafRuleChallenge - | Models.WafRuleRateLimit - | Models.WafRuleRedirect - )[]; - }; - /** * OAuth2 Project */ diff --git a/src/services/account.ts b/src/services/account.ts index 5495849..1714a6f 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -35,49 +30,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -185,49 +138,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -295,38 +206,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2ConsentList', - models: { - oauth2ConsentList: { - defaults: { - total: 0, - }, - properties: { - consents: { - items: 'oauth2Consent', - }, - }, - }, - oauth2Consent: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - appId: '', - cimdUrl: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -381,28 +261,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Consent', - models: { - oauth2Consent: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - appId: '', - cimdUrl: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -539,39 +398,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2ConsentTokenList', - models: { - oauth2ConsentTokenList: { - defaults: { - total: 0, - }, - properties: { - tokens: { - items: 'oauth2ConsentToken', - }, - }, - }, - oauth2ConsentToken: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - consentId: '', - userId: '', - appId: '', - cimdUrl: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -644,29 +471,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2ConsentToken', - models: { - oauth2ConsentToken: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - consentId: '', - userId: '', - appId: '', - cimdUrl: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -820,49 +625,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -930,39 +693,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'identityList', - models: { - identityList: { - defaults: { - total: 0, - }, - properties: { - identities: { - items: 'identity', - }, - }, - }, - identity: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - provider: '', - providerUid: '', - providerEmail: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - providerIdToken: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1078,49 +809,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1178,20 +867,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaType', - models: { - mfaType: { - defaults: { - secret: '', - uri: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1248,20 +924,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaType', - models: { - mfaType: { - defaults: { - secret: '', - uri: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1341,49 +1004,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1462,49 +1083,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1675,22 +1254,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaChallenge', - models: { - mfaChallenge: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1749,22 +1313,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaChallenge', - models: { - mfaChallenge: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1841,47 +1390,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1957,47 +1466,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2017,23 +1486,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaFactors', - models: { - mfaFactors: { - defaults: { - totp: false, - phone: false, - email: false, - recoveryCode: false, - custom: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2052,23 +1505,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaFactors', - models: { - mfaFactors: { - defaults: { - totp: false, - phone: false, - email: false, - recoveryCode: false, - custom: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2088,19 +1525,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2119,19 +1544,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2152,19 +1565,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2184,19 +1585,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2217,19 +1606,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2249,19 +1626,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2321,536 +1686,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Get the list of verified passkeys registered by the currently logged in user. - * - * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listPasskeys(params?: { - queries?: string[]; - total?: boolean; - }): Promise; - /** - * Get the list of verified passkeys registered by the currently logged in user. - * - * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt - * @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. - */ - listPasskeys( - queries?: string[], - total?: boolean, - ): Promise; - listPasskeys( - paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], - ...rest: [boolean?] - ): Promise { - let params: { queries?: string[]; total?: boolean }; - - if ( - (typeof paramsOrFirst === 'undefined' && rest.length === 0) || - (paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst)) - ) { - params = (paramsOrFirst || {}) as { - queries?: string[]; - total?: boolean; - }; - } else { - params = { - queries: paramsOrFirst as string[], - total: rest[0] as boolean, - }; - } - - const queries = params.queries; - const total = params.total; - const apiPath = '/account/passkeys'; - 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', - }; - - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkeyList', - models: { - passkeyList: { - defaults: { - total: 0, - }, - properties: { - passkeys: { - items: 'passkey', - }, - }, - }, - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. - * - * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - */ - createPasskey(params?: { - passkeyId?: string; - name?: string; - }): Promise; - /** - * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. - * - * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createPasskey( - passkeyId?: string, - name?: string, - ): Promise; - createPasskey( - paramsOrFirst?: { passkeyId?: string; name?: string } | string, - ...rest: [string?] - ): Promise { - let params: { passkeyId?: string; name?: string }; - - if ( - (typeof paramsOrFirst === 'undefined' && rest.length === 0) || - (paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst)) - ) { - params = (paramsOrFirst || {}) as { - passkeyId?: string; - name?: string; - }; - } else { - params = { - passkeyId: paramsOrFirst as string, - name: rest[0] as string, - }; - } - - const passkeyId = params.passkeyId; - const name = params.name; - const apiPath = '/account/passkeys'; - const apiPayload: Payload = {}; - if (typeof passkeyId !== 'undefined') { - apiPayload['passkeyId'] = passkeyId; - } - 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', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkeyChallenge', - models: { - passkeyChallenge: { - defaults: { - $id: '', - $createdAt: '', - passkeyId: '', - expire: '', - publicKey: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Get a verified passkey of the currently logged in user by its unique ID. - * - * @param {string} params.passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getPasskey(params: { passkeyId: string }): Promise; - /** - * Get a verified passkey of the currently logged in user by its unique ID. - * - * @param {string} passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getPasskey(passkeyId: string): Promise; - getPasskey( - paramsOrFirst: { passkeyId: string } | string, - ): Promise { - let params: { passkeyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { passkeyId: string }; - } else { - params = { - passkeyId: paramsOrFirst as string, - }; - } - - const passkeyId = params.passkeyId; - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - const apiPath = '/account/passkeys/{passkeyId}'.replace( - '{passkeyId}', - encodeURIComponent(String(passkeyId)), - ); - 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', - }; - - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkey', - models: { - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Rename a passkey of the currently logged in user. - * - * @param {string} params.passkeyId - Passkey ID. - * @param {string} params.name - Passkey name. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasskey(params: { - passkeyId: string; - name: string; - }): Promise; - /** - * Rename a passkey of the currently logged in user. - * - * @param {string} passkeyId - Passkey ID. - * @param {string} name - Passkey name. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasskey(passkeyId: string, name: string): Promise; - updatePasskey( - paramsOrFirst: { passkeyId: string; name: string } | string, - ...rest: [string?] - ): Promise { - let params: { passkeyId: string; name: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - passkeyId: string; - name: string; - }; - } else { - params = { - passkeyId: paramsOrFirst as string, - name: rest[0] as string, - }; - } - - const passkeyId = params.passkeyId; - const name = params.name; - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/account/passkeys/{passkeyId}'.replace( - '{passkeyId}', - encodeURIComponent(String(passkeyId)), - ); - 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', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkey', - models: { - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. - * - * @param {string} params.passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deletePasskey(params: { passkeyId: string }): Promise<{}>; - /** - * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. - * - * @param {string} passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deletePasskey(passkeyId: string): Promise<{}>; - deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { - let params: { passkeyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { passkeyId: string }; - } else { - params = { - passkeyId: paramsOrFirst as string, - }; - } - - const passkeyId = params.passkeyId; - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - const apiPath = '/account/passkeys/{passkeyId}'.replace( - '{passkeyId}', - encodeURIComponent(String(passkeyId)), - ); - 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); - } - - /** - * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. - * - * @param {string} params.passkeyId - Passkey ID. - * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasskeyVerification(params: { - passkeyId: string; - credential: object; - }): Promise; - /** - * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. - * - * @param {string} passkeyId - Passkey ID. - * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasskeyVerification( - passkeyId: string, - credential: object, - ): Promise; - updatePasskeyVerification( - paramsOrFirst: { passkeyId: string; credential: object } | string, - ...rest: [object?] - ): Promise { - let params: { passkeyId: string; credential: object }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - passkeyId: string; - credential: object; - }; - } else { - params = { - passkeyId: paramsOrFirst as string, - credential: rest[0] as object, - }; - } - - const passkeyId = params.passkeyId; - const credential = params.credential; - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - if (typeof credential === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "credential"', - ); - } - const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( - '{passkeyId}', - encodeURIComponent(String(passkeyId)), - ); - const apiPayload: Payload = {}; - if (typeof credential !== 'undefined') { - apiPayload['credential'] = credential; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkey', - models: { - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2929,49 +1765,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3050,49 +1844,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3176,49 +1928,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3286,24 +1996,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3397,24 +2090,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3488,24 +2164,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3597,24 +2256,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3665,57 +2307,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'sessionList', - models: { - sessionList: { - defaults: { - total: 0, - }, - properties: { - sessions: { - items: 'session', - }, - }, - }, - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3787,47 +2379,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3918,47 +2470,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4120,47 +2632,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4235,47 +2707,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4347,47 +2779,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4458,47 +2850,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4553,47 +2905,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4649,47 +2961,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4765,49 +3037,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4898,24 +3128,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5022,24 +3235,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5055,7 +3251,6 @@ export class Account { * @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. - * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} */ @@ -5064,7 +3259,6 @@ export class Account { success?: string; failure?: string; scopes?: string[]; - state?: 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. @@ -5079,7 +3273,6 @@ export class Account { * @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. - * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -5089,7 +3282,6 @@ export class Account { success?: string, failure?: string, scopes?: string[], - state?: string, ): Promise; createOAuth2Token( paramsOrFirst: @@ -5098,17 +3290,15 @@ export class Account { success?: string; failure?: string; scopes?: string[]; - state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?, string?] + ...rest: [string?, string?, string[]?] ): Promise { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; - state?: string; }; if ( @@ -5118,15 +3308,13 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst || - 'state' in paramsOrFirst) + 'scopes' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; - state?: string; }; } else { params = { @@ -5134,7 +3322,6 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], - state: rest[3] as string, }; } @@ -5142,7 +3329,6 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; - const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -5162,9 +3348,6 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } - if (typeof state !== 'undefined') { - apiPayload['state'] = state; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5175,137 +3358,6 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } - /** - * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. - * - * @throws {AppwriteException} - * @returns {Promise} - */ - createPasskeyToken(): Promise { - const apiPath = '/account/tokens/passkey'; - 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', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkeyChallenge', - models: { - passkeyChallenge: { - defaults: { - $id: '', - $createdAt: '', - passkeyId: '', - expire: '', - publicKey: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. - * - * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. - * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasskeyToken(params: { - challengeId: string; - credential: object; - }): Promise; - /** - * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. - * - * @param {string} challengeId - Challenge ID returned by createPasskeyToken. - * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasskeyToken( - challengeId: string, - credential: object, - ): Promise; - updatePasskeyToken( - paramsOrFirst: { challengeId: string; credential: object } | string, - ...rest: [object?] - ): Promise { - let params: { challengeId: string; credential: object }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - challengeId: string; - credential: object; - }; - } else { - params = { - challengeId: paramsOrFirst as string, - credential: rest[0] as object, - }; - } - - const challengeId = params.challengeId; - const credential = params.credential; - if (typeof challengeId === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "challengeId"', - ); - } - if (typeof credential === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "credential"', - ); - } - const apiPath = '/account/tokens/passkey'; - const apiPayload: Payload = {}; - if (typeof challengeId !== 'undefined') { - apiPayload['challengeId'] = challengeId; - } - if (typeof credential !== 'undefined') { - apiPayload['credential'] = credential; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'tokenSecret', - models: { - tokenSecret: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - /** * 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. * @@ -5375,24 +3427,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5452,24 +3487,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5530,24 +3548,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5621,24 +3622,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5710,24 +3694,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5787,24 +3754,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5880,24 +3830,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5917,24 +3850,7 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6008,23 +3924,6 @@ export class Account { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index e0b9039..74bae79 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Activities { @@ -63,57 +58,7 @@ export class Activities { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'activityEventList', - models: { - activityEventList: { - defaults: { - total: 0, - }, - properties: { - events: { - items: 'activityEvent', - }, - }, - }, - activityEvent: { - defaults: { - $id: '', - actorType: '', - actorId: '', - actorEmail: '', - actorName: '', - resourceParent: '', - resourceType: '', - resourceId: '', - resource: '', - event: '', - userAgent: '', - ip: '', - mode: '', - country: '', - continentCode: '', - city: '', - subdivisions: '', - isp: '', - autonomousSystemNumber: '', - autonomousSystemOrganization: '', - connectionType: '', - connectionUsageType: '', - connectionOrganization: '', - time: '', - projectId: '', - teamId: '', - hostname: '', - sdk: '', - sdkVersion: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -170,46 +115,6 @@ export class Activities { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'activityEvent', - models: { - activityEvent: { - defaults: { - $id: '', - actorType: '', - actorId: '', - actorEmail: '', - actorName: '', - resourceParent: '', - resourceType: '', - resourceId: '', - resource: '', - event: '', - userAgent: '', - ip: '', - mode: '', - country: '', - continentCode: '', - city: '', - subdivisions: '', - isp: '', - autonomousSystemNumber: '', - autonomousSystemOrganization: '', - connectionType: '', - connectionUsageType: '', - connectionOrganization: '', - time: '', - projectId: '', - teamId: '', - hostname: '', - sdk: '', - sdkVersion: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 5e01ab0..0ffcdfb 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Advisor { @@ -80,73 +75,7 @@ export class Advisor { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'reportList', - models: { - reportList: { - defaults: { - total: 0, - }, - properties: { - reports: { - items: 'report', - }, - }, - }, - report: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - type: '', - title: '', - summary: '', - targetType: '', - target: '', - categories: [], - }, - properties: { - insights: { - items: 'insight', - }, - }, - }, - insight: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - reportId: '', - type: '', - severity: 'info', - status: 'active', - resourceType: '', - resourceId: '', - parentResourceType: '', - parentResourceId: '', - title: '', - summary: '', - }, - properties: { - ctas: { - items: 'insightCTA', - }, - }, - }, - insightCTA: { - defaults: { - label: '', - service: '', - method: '', - params: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -203,63 +132,7 @@ export class Advisor { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'report', - models: { - report: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - type: '', - title: '', - summary: '', - targetType: '', - target: '', - categories: [], - }, - properties: { - insights: { - items: 'insight', - }, - }, - }, - insight: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - reportId: '', - type: '', - severity: 'info', - status: 'active', - resourceType: '', - resourceId: '', - parentResourceType: '', - parentResourceId: '', - title: '', - summary: '', - }, - properties: { - ctas: { - items: 'insightCTA', - }, - }, - }, - insightCTA: { - defaults: { - label: '', - service: '', - method: '', - params: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -400,54 +273,7 @@ export class Advisor { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'insightList', - models: { - insightList: { - defaults: { - total: 0, - }, - properties: { - insights: { - items: 'insight', - }, - }, - }, - insight: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - reportId: '', - type: '', - severity: 'info', - status: 'active', - resourceType: '', - resourceId: '', - parentResourceType: '', - parentResourceId: '', - title: '', - summary: '', - }, - properties: { - ctas: { - items: 'insightCTA', - }, - }, - }, - insightCTA: { - defaults: { - label: '', - service: '', - method: '', - params: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -519,43 +345,6 @@ export class Advisor { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'insight', - models: { - insight: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - reportId: '', - type: '', - severity: 'info', - status: 'active', - resourceType: '', - resourceId: '', - parentResourceType: '', - parentResourceId: '', - title: '', - summary: '', - }, - properties: { - ctas: { - items: 'insightCTA', - }, - }, - }, - insightCTA: { - defaults: { - label: '', - service: '', - method: '', - params: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index f7e4461..54b4b2c 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Apps { @@ -75,70 +70,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appsList', - models: { - appsList: { - defaults: { - total: 0, - }, - properties: { - apps: { - items: 'app', - }, - }, - }, - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -448,60 +380,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'app', - models: { - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -520,33 +399,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appScopeList', - models: { - appScopeList: { - defaults: { - total: 0, - }, - properties: { - scopes: { - items: 'appScope', - }, - }, - }, - appScope: { - defaults: { - value: '', - description: '', - type: '', - category: '', - deprecated: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -565,33 +418,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appScopeList', - models: { - appScopeList: { - defaults: { - total: 0, - }, - properties: { - scopes: { - items: 'appScope', - }, - }, - }, - appScope: { - defaults: { - value: '', - description: '', - type: '', - category: '', - deprecated: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -642,60 +469,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'app', - models: { - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1013,60 +787,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'app', - models: { - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1199,37 +920,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallationList', - models: { - appInstallationList: { - defaults: { - total: 0, - }, - properties: { - installations: { - items: 'appInstallation', - }, - }, - }, - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1303,27 +994,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1470,23 +1141,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Token', - models: { - oauth2Token: { - defaults: { - access_token: '', - token_type: 'Bearer', - expires_in: 0, - refresh_token: '', - scope: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1567,36 +1222,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appKeyList', - models: { - appKeyList: { - defaults: { - total: 0, - }, - properties: { - keys: { - items: 'appKey', - }, - }, - }, - appKey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1650,26 +1276,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appKey', - models: { - appKey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1729,26 +1336,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appKey', - models: { - appKey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1880,60 +1468,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'app', - models: { - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2014,36 +1549,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appSecretList', - models: { - appSecretList: { - defaults: { - total: 0, - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2097,26 +1603,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appSecretPlaintext', - models: { - appSecretPlaintext: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2184,26 +1671,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appSecret', - models: { - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2334,60 +1802,7 @@ export class Apps { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'app', - models: { - app: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - clientUri: '', - logoUri: '', - privacyPolicyUrl: '', - termsUrl: '', - contacts: [], - tagline: '', - tags: [], - labels: [], - images: [], - supportUrl: '', - dataDeletionUrl: '', - redirectUris: [], - postLogoutRedirectUris: [], - enabled: true, - type: 'confidential', - deviceFlow: false, - teamId: '', - userId: '', - installationScopes: [], - installationRedirectUrl: '', - }, - properties: { - secrets: { - items: 'appSecret', - }, - }, - }, - appSecret: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - secret: '', - hint: '', - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 5fa9e52..6faed76 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -3,7 +3,6 @@ import { Client, type Payload, UploadProgress, - applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; diff --git a/src/services/backups.ts b/src/services/backups.ts index 87d5ef2..633bb09 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -64,34 +59,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupArchiveList', - models: { - backupArchiveList: { - defaults: { - total: 0, - }, - properties: { - archives: { - items: 'backupArchive', - }, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -167,24 +135,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupArchive', - models: { - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -239,24 +190,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupArchive', - models: { - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -363,36 +297,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicyList', - models: { - backupPolicyList: { - defaults: { - total: 0, - }, - properties: { - policies: { - items: 'backupPolicy', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -555,26 +460,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -629,26 +515,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -765,26 +632,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -966,26 +814,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupRestoration', - models: { - backupRestoration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - archiveId: '', - policyId: '', - status: '', - migrationId: '', - options: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1038,36 +867,7 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupRestorationList', - models: { - backupRestorationList: { - defaults: { - total: 0, - }, - properties: { - restorations: { - items: 'backupRestoration', - }, - }, - }, - backupRestoration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - archiveId: '', - policyId: '', - status: '', - migrationId: '', - options: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1124,25 +924,6 @@ export class Backups { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupRestoration', - models: { - backupRestoration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - archiveId: '', - policyId: '', - status: '', - migrationId: '', - options: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 7f65790..03929fd 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -94,64 +89,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseList', - models: { - databaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'database', - }, - }, - }, - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -241,54 +179,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -357,34 +248,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transactionList', - models: { - transactionList: { - defaults: { - total: 0, - }, - properties: { - transactions: { - items: 'transaction', - }, - }, - }, - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -437,24 +301,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -512,24 +359,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -619,24 +449,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -769,24 +582,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -842,54 +638,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -974,54 +723,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1181,54 +883,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collectionList', - models: { - collectionList: { - defaults: { - total: 0, - }, - properties: { - collections: { - items: 'collection', - }, - }, - }, - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1398,44 +1053,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1512,44 +1130,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1695,44 +1276,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1917,19 +1461,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeList', - models: { - attributeList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2106,24 +1638,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeBigint', - models: { - attributeBigint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2303,24 +1818,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeBigint', - models: { - attributeBigint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2465,24 +1963,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeBoolean', - models: { - attributeBoolean: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2628,24 +2109,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeBoolean', - models: { - attributeBoolean: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2788,24 +2252,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeDatetime', - models: { - attributeDatetime: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2951,24 +2398,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeDatetime', - models: { - attributeDatetime: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3113,25 +2543,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeEmail', - models: { - attributeEmail: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'email', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3279,25 +2691,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeEmail', - models: { - attributeEmail: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'email', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3459,25 +2853,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeEnum', - models: { - attributeEnum: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'enum', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3642,25 +3018,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeEnum', - models: { - attributeEnum: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'enum', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3837,24 +3195,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeFloat', - models: { - attributeFloat: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4034,24 +3375,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeFloat', - models: { - attributeFloat: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4228,24 +3552,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeInteger', - models: { - attributeInteger: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4425,24 +3732,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeInteger', - models: { - attributeInteger: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4587,25 +3877,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeIp', - models: { - attributeIp: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'ip', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4753,25 +4025,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeIp', - models: { - attributeIp: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'ip', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4902,24 +4156,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeLine', - models: { - attributeLine: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5060,24 +4297,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeLine', - models: { - attributeLine: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5234,24 +4454,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeLongtext', - models: { - attributeLongtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5399,24 +4602,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeLongtext', - models: { - attributeLongtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5573,24 +4759,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeMediumtext', - models: { - attributeMediumtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5738,24 +4907,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeMediumtext', - models: { - attributeMediumtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5886,24 +5038,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributePoint', - models: { - attributePoint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6044,24 +5179,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributePoint', - models: { - attributePoint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6192,24 +5310,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributePolygon', - models: { - attributePolygon: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6350,24 +5451,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributePolygon', - models: { - attributePolygon: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6544,29 +5628,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeRelationship', - models: { - attributeRelationship: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - relationType: '', - twoWay: false, - twoWayKey: '', - onDelete: 'restrict', - side: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6692,29 +5754,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeRelationship', - models: { - attributeRelationship: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - relationType: '', - twoWay: false, - twoWayKey: '', - onDelete: 'restrict', - side: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6894,25 +5934,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeString', - models: { - attributeString: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7072,25 +6094,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeString', - models: { - attributeString: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7247,24 +6251,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeText', - models: { - attributeText: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7412,24 +6399,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeText', - models: { - attributeText: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7574,25 +6544,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeUrl', - models: { - attributeUrl: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'url', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7740,25 +6692,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeUrl', - models: { - attributeUrl: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'url', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7938,25 +6872,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeVarchar', - models: { - attributeVarchar: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8116,25 +7032,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'attributeVarchar', - models: { - attributeVarchar: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8508,34 +7406,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8705,24 +7576,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8840,34 +7694,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8987,34 +7814,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -9139,34 +7939,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9279,34 +8052,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -9436,24 +8182,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -9623,24 +8352,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -9810,24 +8522,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10103,24 +8798,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10279,24 +8957,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10406,36 +9067,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'indexList', - models: { - indexList: { - defaults: { - total: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -10602,26 +9234,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -10711,26 +9324,7 @@ export class Databases { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index bb8ed5c..823cf87 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -77,64 +72,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseList', - models: { - databaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'database', - }, - }, - }, - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -268,54 +206,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -334,41 +225,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -436,34 +293,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transactionList', - models: { - transactionList: { - defaults: { - total: 0, - }, - properties: { - transactions: { - items: 'transaction', - }, - }, - }, - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -515,24 +345,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -589,24 +402,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -695,24 +491,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -843,24 +622,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -915,54 +677,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1094,54 +809,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1299,54 +967,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collectionList', - models: { - collectionList: { - defaults: { - total: 0, - }, - properties: { - collections: { - items: 'collection', - }, - }, - }, - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1515,44 +1136,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1628,44 +1212,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1813,44 +1360,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'collection', - models: { - collection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2059,34 +1569,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2255,24 +1738,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2389,34 +1855,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2535,34 +1974,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2686,34 +2098,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2825,34 +2210,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2981,24 +2339,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3167,24 +2508,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3353,24 +2677,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3644,24 +2951,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3819,24 +3109,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3945,36 +3218,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'indexList', - models: { - indexList: { - defaults: { - total: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4140,26 +3384,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4248,26 +3473,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4431,63 +3637,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4591,36 +3741,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4677,35 +3798,7 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4760,49 +3853,6 @@ export class DocumentsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 8d3180e..7550437 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -76,60 +71,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domainsList', - models: { - domainsList: { - defaults: { - total: 0, - }, - properties: { - domains: { - items: 'domain', - }, - }, - }, - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -197,50 +139,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -331,24 +230,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domainPrice', - models: { - domainPrice: { - defaults: { - domain: '', - tld: '', - available: false, - periodYears: 1, - premium: false, - renewalPeriodYears: 1, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -440,34 +322,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domainPricesList', - models: { - domainPricesList: { - defaults: { - total: 0, - }, - properties: { - prices: { - items: 'domainPrice', - }, - }, - }, - domainPrice: { - defaults: { - domain: '', - tld: '', - available: false, - periodYears: 1, - premium: false, - renewalPeriodYears: 1, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -520,50 +375,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -694,50 +506,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -797,50 +566,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -897,40 +623,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -992,40 +685,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1082,40 +742,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1175,40 +802,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1265,40 +859,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1358,40 +919,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1448,40 +976,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1541,40 +1036,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1631,40 +1093,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1724,40 +1153,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1812,40 +1208,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1905,40 +1268,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2012,40 +1342,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecordsList', - models: { - dnsRecordsList: { - defaults: { - total: 0, - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2173,30 +1470,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2339,30 +1613,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2490,30 +1741,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2656,30 +1884,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2809,30 +2014,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2979,30 +2161,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3130,30 +2289,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3296,30 +2432,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3453,30 +2566,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3615,30 +2705,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3766,30 +2833,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3932,30 +2976,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4104,30 +3125,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4283,30 +3281,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4434,30 +3409,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4602,30 +3554,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -4802,30 +3731,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5046,30 +3952,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5196,30 +4079,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5364,30 +4224,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -5465,30 +4302,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dnsRecord', - models: { - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5639,50 +4453,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5739,21 +4510,7 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domainTransferStatus', - models: { - domainTransferStatus: { - defaults: { - status: 'pending_registry', - reason: '', - timestamp: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5885,49 +4642,6 @@ export class Domains { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'domain', - models: { - domain: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - registrar: '', - nameservers: '', - expire: '', - renewal: '', - autoRenewal: false, - renewalPrice: 0, - teamId: '', - }, - properties: { - dnsRecords: { - items: 'dnsRecord', - }, - }, - }, - dnsRecord: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - name: '', - value: '', - ttl: 3600, - priority: 0, - lock: false, - weight: 0, - port: 0, - comment: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index cdc8d3e..ff08ad9 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -84,31 +79,6 @@ export class Embeddings { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'embeddingList', - models: { - embeddingList: { - defaults: { - total: 0, - }, - properties: { - embeddings: { - items: 'embedding', - }, - }, - }, - embedding: { - defaults: { - model: '', - dimension: 0, - embedding: [], - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index c46c201..8af9565 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,7 +3,6 @@ import { Client, type Payload, UploadProgress, - applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,76 +96,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'functionList', - models: { - functionList: { - defaults: { - total: 0, - }, - properties: { - functions: { - items: 'function', - }, - }, - }, - function: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - execute: [], - name: '', - enabled: true, - live: true, - logging: true, - runtime: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - events: [], - schedule: '', - timeout: 15, - entrypoint: '', - commands: '', - version: 'v5', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -177,7 +107,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. + * @param {string} params.schedule - Schedule CRON syntax. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -194,7 +124,6 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. - * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} */ @@ -221,7 +150,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: 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. @@ -231,7 +159,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. + * @param {string} schedule - Schedule CRON syntax. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -248,7 +176,6 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. - * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -276,7 +203,6 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, - interval?: number, ): Promise; create( paramsOrFirst: @@ -303,7 +229,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; } | string, ...rest: [ @@ -328,7 +253,6 @@ export class Functions { string?, string?, number?, - number?, ] ): Promise { let params: { @@ -354,7 +278,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; }; if ( @@ -385,7 +308,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; }; } else { params = { @@ -411,7 +333,6 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, - interval: rest[21] as number, }; } @@ -437,7 +358,6 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -519,9 +439,6 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } - if (typeof interval !== 'undefined') { - apiPayload['interval'] = interval; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -530,66 +447,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'function', - models: { - function: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - execute: [], - name: '', - enabled: true, - live: true, - logging: true, - runtime: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - events: [], - schedule: '', - timeout: 15, - entrypoint: '', - commands: '', - version: 'v5', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -640,35 +498,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'runtimeList', - models: { - runtimeList: { - defaults: { - total: 0, - }, - properties: { - runtimes: { - items: 'runtime', - }, - }, - }, - runtime: { - defaults: { - $id: '', - key: '', - name: '', - version: '', - base: '', - image: '', - logo: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -736,32 +566,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'specificationList', - models: { - specificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'specification', - }, - }, - }, - specification: { - defaults: { - memory: 0, - cpus: 0, - enabled: false, - slug: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -816,66 +621,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'function', - models: { - function: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - execute: [], - name: '', - enabled: true, - live: true, - logging: true, - runtime: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - events: [], - schedule: '', - timeout: 15, - entrypoint: '', - commands: '', - version: 'v5', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -886,7 +632,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. + * @param {string} params.schedule - Schedule CRON syntax. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -903,7 +649,6 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. - * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} */ @@ -930,7 +675,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; }): Promise; /** * Update function by its unique ID. @@ -940,7 +684,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. + * @param {string} schedule - Schedule CRON syntax. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -957,7 +701,6 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. - * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -985,7 +728,6 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, - interval?: number, ): Promise; update( paramsOrFirst: @@ -1012,7 +754,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; } | string, ...rest: [ @@ -1037,7 +778,6 @@ export class Functions { string?, string?, number?, - number?, ] ): Promise { let params: { @@ -1063,7 +803,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; }; if ( @@ -1094,7 +833,6 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; - interval?: number; }; } else { params = { @@ -1120,7 +858,6 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, - interval: rest[21] as number, }; } @@ -1146,7 +883,6 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; - const interval = params.interval; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -1223,9 +959,6 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } - if (typeof interval !== 'undefined') { - apiPayload['interval'] = interval; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1234,66 +967,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'function', - models: { - function: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - execute: [], - name: '', - enabled: true, - live: true, - logging: true, - runtime: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - events: [], - schedule: '', - timeout: 15, - entrypoint: '', - commands: '', - version: 'v5', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1425,66 +1099,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'function', - models: { - function: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - execute: [], - name: '', - enabled: true, - live: true, - logging: true, - runtime: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - events: [], - schedule: '', - timeout: 15, - entrypoint: '', - commands: '', - version: 'v5', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1588,54 +1203,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deploymentList', - models: { - deploymentList: { - defaults: { - total: 0, - }, - properties: { - deployments: { - items: 'deployment', - }, - }, - }, - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1882,44 +1450,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2092,44 +1623,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2246,44 +1740,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2359,44 +1816,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2663,44 +2083,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2784,55 +2167,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'executionList', - models: { - executionList: { - defaults: { - total: 0, - }, - properties: { - executions: { - items: 'execution', - }, - }, - }, - execution: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - resourceId: '', - resourceType: 'functions', - deploymentId: '', - requestMethod: '', - requestPath: '', - responseStatusCode: 0, - responseBody: '', - logs: '', - errors: '', - duration: 0, - }, - properties: { - requestHeaders: { - items: 'headers', - }, - responseHeaders: { - items: 'headers', - }, - }, - }, - headers: { - defaults: { - name: '', - value: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2980,45 +2315,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'execution', - models: { - execution: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - resourceId: '', - resourceType: 'functions', - deploymentId: '', - requestMethod: '', - requestPath: '', - responseStatusCode: 0, - responseBody: '', - logs: '', - errors: '', - duration: 0, - }, - properties: { - requestHeaders: { - items: 'headers', - }, - responseHeaders: { - items: 'headers', - }, - }, - }, - headers: { - defaults: { - name: '', - value: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3091,45 +2388,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'execution', - models: { - execution: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - resourceId: '', - resourceType: 'functions', - deploymentId: '', - requestMethod: '', - requestPath: '', - responseStatusCode: 0, - responseBody: '', - logs: '', - errors: '', - duration: 0, - }, - properties: { - requestHeaders: { - items: 'headers', - }, - responseHeaders: { - items: 'headers', - }, - }, - }, - headers: { - defaults: { - name: '', - value: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3284,36 +2543,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variableList', - models: { - variableList: { - defaults: { - total: 0, - }, - properties: { - variables: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3441,26 +2671,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3533,26 +2744,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3670,26 +2862,7 @@ export class Functions { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index b620ed0..949a1e5 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload, applyDefaults } from '../client'; +import { Client, type Payload } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,25 +26,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'locale', - models: { - locale: { - defaults: { - ip: '', - countryCode: '', - country: '', - continentCode: '', - continent: '', - eu: false, - currency: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -95,30 +77,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'localeCodeList', - models: { - localeCodeList: { - defaults: { - total: 0, - }, - properties: { - localeCodes: { - items: 'localeCode', - }, - }, - }, - localeCode: { - defaults: { - code: '', - name: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -169,30 +128,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'continentList', - models: { - continentList: { - defaults: { - total: 0, - }, - properties: { - continents: { - items: 'continent', - }, - }, - }, - continent: { - defaults: { - name: '', - code: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -243,30 +179,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'countryList', - models: { - countryList: { - defaults: { - total: 0, - }, - properties: { - countries: { - items: 'country', - }, - }, - }, - country: { - defaults: { - name: '', - code: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -317,30 +230,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'countryList', - models: { - countryList: { - defaults: { - total: 0, - }, - properties: { - countries: { - items: 'country', - }, - }, - }, - country: { - defaults: { - name: '', - code: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -393,31 +283,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'phoneList', - models: { - phoneList: { - defaults: { - total: 0, - }, - properties: { - phones: { - items: 'phone', - }, - }, - }, - phone: { - defaults: { - code: '', - countryCode: '', - countryName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -468,35 +334,7 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'currencyList', - models: { - currencyList: { - defaults: { - total: 0, - }, - properties: { - currencies: { - items: 'currency', - }, - }, - }, - currency: { - defaults: { - symbol: '', - name: '', - symbolNative: '', - decimalDigits: 0, - rounding: 0, - code: '', - namePlural: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -547,30 +385,6 @@ export class Locale { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'languageList', - models: { - languageList: { - defaults: { - total: 0, - }, - properties: { - languages: { - items: 'language', - }, - }, - }, - language: { - defaults: { - name: '', - code: '', - nativeName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index bdc8ad3..2225646 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -91,35 +86,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'messageList', - models: { - messageList: { - defaults: { - total: 0, - }, - properties: { - messages: { - items: 'message', - }, - }, - }, - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -368,25 +335,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -627,25 +576,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -962,25 +893,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1299,25 +1212,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1464,25 +1359,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1628,25 +1505,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1790,25 +1649,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1951,25 +1792,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2026,25 +1849,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'message', - models: { - message: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - providerType: '', - deliveredTotal: 0, - data: [], - status: 'draft', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2181,36 +1986,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'targetList', - models: { - targetList: { - defaults: { - total: 0, - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2289,36 +2065,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'providerList', - models: { - providerList: { - defaults: { - total: 0, - }, - properties: { - providers: { - items: 'provider', - }, - }, - }, - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2483,26 +2230,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2666,26 +2394,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2847,26 +2556,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3027,26 +2717,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3166,26 +2837,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3302,26 +2954,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3430,26 +3063,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3557,26 +3171,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3682,26 +3277,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3806,26 +3382,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4015,26 +3572,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4221,26 +3759,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4372,26 +3891,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4520,26 +4020,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4703,26 +4184,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4883,26 +4345,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5066,26 +4509,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5246,26 +4670,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5455,26 +4860,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5661,26 +5047,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5926,26 +5293,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6190,26 +5538,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6449,26 +5778,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6707,26 +6017,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6858,26 +6149,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7006,26 +6278,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7157,26 +6410,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7305,26 +6539,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7456,26 +6671,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7604,26 +6800,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7755,26 +6932,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7903,26 +7061,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7979,26 +7118,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'provider', - models: { - provider: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - provider: '', - enabled: true, - type: '', - credentials: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8133,36 +7253,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'topicList', - models: { - topicList: { - defaults: { - total: 0, - }, - properties: { - topics: { - items: 'topic', - }, - }, - }, - topic: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - emailTotal: 0, - smsTotal: 0, - pushTotal: 0, - subscribe: ['users'], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8282,26 +7373,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'topic', - models: { - topic: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - emailTotal: 0, - smsTotal: 0, - pushTotal: 0, - subscribe: ['users'], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8358,26 +7430,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'topic', - models: { - topic: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - emailTotal: 0, - smsTotal: 0, - pushTotal: 0, - subscribe: ['users'], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8496,26 +7549,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'topic', - models: { - topic: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - emailTotal: 0, - smsTotal: 0, - pushTotal: 0, - subscribe: ['users'], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8673,36 +7707,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'subscriberList', - models: { - subscriberList: { - defaults: { - total: 0, - }, - properties: { - subscribers: { - items: 'subscriber', - }, - }, - }, - subscriber: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - targetId: '', - userId: '', - userName: '', - topicId: '', - providerType: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8797,26 +7802,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'subscriber', - models: { - subscriber: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - targetId: '', - userId: '', - userName: '', - topicId: '', - providerType: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8894,26 +7880,7 @@ export class Messaging { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'subscriber', - models: { - subscriber: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - targetId: '', - userId: '', - userName: '', - topicId: '', - providerType: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index 4c4e6b4..e4ce1d9 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Mongo { @@ -63,73 +58,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseList', - models: { - dedicatedDatabaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'dedicatedDatabase', - }, - }, - }, - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -373,63 +302,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -448,41 +321,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -537,63 +376,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -927,63 +710,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1109,40 +836,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupList', - models: { - dedicatedDatabaseBackupList: { - defaults: { - total: 0, - }, - properties: { - backups: { - items: 'dedicatedDatabaseBackup', - }, - }, - }, - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1215,30 +909,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1310,36 +981,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicyList', - models: { - backupPolicyList: { - defaults: { - total: 0, - }, - properties: { - policies: { - items: 'backupPolicy', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1498,26 +1140,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1590,26 +1213,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1739,26 +1343,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2000,23 +1585,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupStorage', - models: { - dedicatedDatabaseBackupStorage: { - defaults: { - provider: '', - bucket: '', - region: '', - prefix: 'backups/', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2089,30 +1658,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2239,39 +1785,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBranchList', - models: { - dedicatedDatabaseBranchList: { - defaults: { - total: 0, - }, - properties: { - branches: { - items: 'dedicatedDatabaseBranch', - }, - }, - }, - dedicatedDatabaseBranch: { - defaults: { - branchId: '', - branchName: '', - namespace: '', - expiresAt: 0, - host: '', - database: '', - username: '', - password: '', - ssl: false, - engine: '', - connectionString: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2355,63 +1869,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2485,63 +1943,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2601,26 +2003,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperation', - models: { - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2694,63 +2077,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2842,63 +2169,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2992,63 +2263,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3152,36 +2367,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3238,20 +2424,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePITRWindows', - models: { - dedicatedDatabasePITRWindows: { - defaults: { - earliest: '', - latest: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3308,35 +2481,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3452,35 +2597,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestorationList', - models: { - dedicatedDatabaseRestorationList: { - defaults: { - total: 0, - }, - properties: { - restorations: { - items: 'dedicatedDatabaseRestoration', - }, - }, - }, - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3597,25 +2714,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3691,25 +2790,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3764,50 +2845,7 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3885,62 +2923,6 @@ export class Mongo { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index baa489e..701198f 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Mysql { @@ -63,73 +58,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseList', - models: { - dedicatedDatabaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'dedicatedDatabase', - }, - }, - }, - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -373,63 +302,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -448,41 +321,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -537,63 +376,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -927,63 +710,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1109,40 +836,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupList', - models: { - dedicatedDatabaseBackupList: { - defaults: { - total: 0, - }, - properties: { - backups: { - items: 'dedicatedDatabaseBackup', - }, - }, - }, - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1215,30 +909,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1310,36 +981,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicyList', - models: { - backupPolicyList: { - defaults: { - total: 0, - }, - properties: { - policies: { - items: 'backupPolicy', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1498,26 +1140,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1590,26 +1213,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1739,26 +1343,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2000,23 +1585,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupStorage', - models: { - dedicatedDatabaseBackupStorage: { - defaults: { - provider: '', - bucket: '', - region: '', - prefix: 'backups/', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2089,30 +1658,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2239,39 +1785,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBranchList', - models: { - dedicatedDatabaseBranchList: { - defaults: { - total: 0, - }, - properties: { - branches: { - items: 'dedicatedDatabaseBranch', - }, - }, - }, - dedicatedDatabaseBranch: { - defaults: { - branchId: '', - branchName: '', - namespace: '', - expiresAt: 0, - host: '', - database: '', - username: '', - password: '', - ssl: false, - engine: '', - connectionString: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2355,63 +1869,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2485,63 +1943,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2601,26 +2003,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperation', - models: { - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2728,34 +2111,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseExecution', - models: { - dedicatedDatabaseExecution: { - defaults: { - rows: [], - rowCount: 0, - durationMs: 0, - truncated: false, - bytes: 0, - }, - properties: { - columns: { - items: 'dedicatedDatabaseExecutionColumn', - }, - }, - }, - dedicatedDatabaseExecutionColumn: { - defaults: { - name: '', - type: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2829,63 +2185,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2977,63 +2277,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3127,63 +2371,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3287,36 +2475,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3373,20 +2532,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePITRWindows', - models: { - dedicatedDatabasePITRWindows: { - defaults: { - earliest: '', - latest: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3443,28 +2589,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePooler', - models: { - dedicatedDatabasePooler: { - defaults: { - enabled: false, - mode: 'transaction', - maxConnections: 100, - defaultPoolSize: 20, - port: 6432, - readWriteSplitting: false, - poolerCpuRequest: '', - poolerCpuLimit: '', - poolerMemoryRequest: '', - poolerMemoryLimit: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3638,28 +2763,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePooler', - models: { - dedicatedDatabasePooler: { - defaults: { - enabled: false, - mode: 'transaction', - maxConnections: 100, - defaultPoolSize: 20, - port: 6432, - readWriteSplitting: false, - poolerCpuRequest: '', - poolerCpuLimit: '', - poolerMemoryRequest: '', - poolerMemoryLimit: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3716,35 +2820,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3860,35 +2936,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestorationList', - models: { - dedicatedDatabaseRestorationList: { - defaults: { - total: 0, - }, - properties: { - restorations: { - items: 'dedicatedDatabaseRestoration', - }, - }, - }, - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4005,25 +3053,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4099,25 +3129,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4172,50 +3184,7 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4293,62 +3262,6 @@ export class Mysql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 3cc7c93..31f94b9 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -101,19 +96,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Approve', - models: { - oauth2Approve: { - defaults: { - redirectUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -130,7 +113,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -148,7 +131,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }): Promise; @@ -166,7 +149,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -185,7 +168,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string[], + resource?: string, audience?: string, requestUri?: string, ): Promise; @@ -203,7 +186,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; } @@ -219,7 +202,7 @@ export class Oauth2 { string?, number?, string?, - string[]?, + string?, string?, string?, ] @@ -236,7 +219,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }; @@ -259,7 +242,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }; @@ -276,7 +259,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string[], + resource: rest[10] as string, audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -349,20 +332,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Authorize', - models: { - oauth2Authorize: { - defaults: { - grantId: '', - redirectUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -379,7 +349,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -397,7 +367,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }): Promise; @@ -415,7 +385,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -434,7 +404,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string[], + resource?: string, audience?: string, requestUri?: string, ): Promise; @@ -452,7 +422,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; } @@ -468,7 +438,7 @@ export class Oauth2 { string?, number?, string?, - string[]?, + string?, string?, string?, ] @@ -485,7 +455,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }; @@ -508,7 +478,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; requestUri?: string; }; @@ -525,7 +495,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string[], + resource: rest[10] as string, audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -599,20 +569,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Authorize', - models: { - oauth2Authorize: { - defaults: { - grantId: '', - redirectUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -621,7 +578,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -630,7 +587,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }): Promise; /** @@ -639,7 +596,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -649,7 +606,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string[], + resource?: string, audience?: string, ): Promise; createDeviceAuthorization( @@ -658,17 +615,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; } | string, - ...rest: [string?, string?, string[]?, string?] + ...rest: [string?, string?, string?, string?] ): Promise { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }; @@ -682,7 +639,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }; } else { @@ -690,7 +647,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string[], + resource: rest[2] as string, audience: rest[3] as string, }; } @@ -727,24 +684,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2DeviceAuthorization', - models: { - oauth2DeviceAuthorization: { - defaults: { - device_code: '', - user_code: '', - verification_uri: '', - verification_uri_complete: '', - expires_in: 0, - interval: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -802,30 +742,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Grant', - models: { - oauth2Grant: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - appId: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - prompt: '', - redirectUri: '', - authTime: 0, - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -881,30 +798,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Grant', - models: { - oauth2Grant: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - appId: '', - scopes: [], - resources: [], - authorizationDetails: '[]', - prompt: '', - redirectUri: '', - authTime: 0, - expire: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1009,19 +903,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Introspection', - models: { - oauth2Introspection: { - defaults: { - active: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1102,29 +984,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2OrganizationList', - models: { - oauth2OrganizationList: { - defaults: { - total: 0, - }, - properties: { - organizations: { - items: 'oauth2Organization', - }, - }, - }, - oauth2Organization: { - defaults: { - $id: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1141,7 +1001,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1158,7 +1018,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }): Promise; /** @@ -1175,7 +1035,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1193,7 +1053,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string[], + resource?: string, audience?: string, ): Promise; createPAR( @@ -1210,7 +1070,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; } | string, @@ -1225,7 +1085,7 @@ export class Oauth2 { string?, number?, string?, - string[]?, + string?, string?, ] ): Promise { @@ -1241,7 +1101,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }; @@ -1262,7 +1122,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string[]; + resource?: string; audience?: string; }; } else { @@ -1278,7 +1138,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string[], + resource: rest[10] as string, audience: rest[11] as string, }; } @@ -1362,20 +1222,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2PAR', - models: { - oauth2PAR: { - defaults: { - request_uri: '', - expires_in: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1456,31 +1303,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2ProjectList', - models: { - oauth2ProjectList: { - defaults: { - total: 0, - }, - properties: { - projects: { - items: 'oauth2Project', - }, - }, - }, - oauth2Project: { - defaults: { - $id: '', - region: '', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1538,19 +1361,7 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Reject', - models: { - oauth2Reject: { - defaults: { - redirectUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1669,7 +1480,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1683,7 +1494,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string[]; + resource?: string; audience?: string; }): Promise; /** @@ -1697,7 +1508,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise} @@ -1712,7 +1523,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string[], + resource?: string, audience?: string, ): Promise; createToken( @@ -1726,7 +1537,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string[]; + resource?: string; audience?: string; } | string, @@ -1738,7 +1549,7 @@ export class Oauth2 { string?, string?, string?, - string[]?, + string?, string?, ] ): Promise { @@ -1751,7 +1562,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string[]; + resource?: string; audience?: string; }; @@ -1769,7 +1580,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string[]; + resource?: string; audience?: string; }; } else { @@ -1782,7 +1593,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string[], + resource: rest[7] as string, audience: rest[8] as string, }; } @@ -1844,22 +1655,6 @@ export class Oauth2 { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oauth2Token', - models: { - oauth2Token: { - defaults: { - access_token: '', - token_type: 'Bearer', - expires_in: 0, - refresh_token: '', - scope: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 72fd5e2..955a696 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -33,31 +28,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'organization', - models: { - organization: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - budgetAlerts: [75], - billingPlan: 'tier-0', - billingPlanId: 'tier-0', - billingEmail: '', - status: 'draft', - markedForDeletion: false, - platform: 'appwrite', - projects: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -115,31 +86,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'organization', - models: { - organization: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - budgetAlerts: [75], - billingPlan: 'tier-0', - billingPlanId: 'tier-0', - billingEmail: '', - status: 'draft', - markedForDeletion: false, - platform: 'appwrite', - projects: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -227,37 +174,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallationList', - models: { - appInstallationList: { - defaults: { - total: 0, - }, - properties: { - installations: { - items: 'appInstallation', - }, - }, - }, - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -329,27 +246,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -406,27 +303,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -500,27 +377,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -655,43 +512,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membershipList', - models: { - membershipList: { - defaults: { - total: 0, - }, - properties: { - memberships: { - items: 'membership', - }, - }, - }, - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -818,33 +639,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -899,33 +694,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1001,33 +770,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1162,87 +905,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'projectList', - models: { - projectList: { - defaults: { - total: 0, - }, - properties: { - projects: { - items: 'project', - }, - }, - }, - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1329,77 +992,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1454,77 +1047,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1597,77 +1120,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1804,36 +1257,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'keyList', - models: { - keyList: { - defaults: { - total: 0, - }, - properties: { - keys: { - items: 'key', - }, - }, - }, - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1939,26 +1363,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'ephemeralKey', - models: { - ephemeralKey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2026,26 +1431,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'key', - models: { - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2167,26 +1553,7 @@ export class Organization { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'key', - models: { - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index 706df5a..ec5659b 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -63,73 +58,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseList', - models: { - dedicatedDatabaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'dedicatedDatabase', - }, - }, - }, - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -373,63 +302,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -448,41 +321,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -537,63 +376,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -927,63 +710,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1109,40 +836,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupList', - models: { - dedicatedDatabaseBackupList: { - defaults: { - total: 0, - }, - properties: { - backups: { - items: 'dedicatedDatabaseBackup', - }, - }, - }, - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1215,30 +909,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1310,36 +981,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicyList', - models: { - backupPolicyList: { - defaults: { - total: 0, - }, - properties: { - policies: { - items: 'backupPolicy', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1498,26 +1140,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1590,26 +1213,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1739,26 +1343,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'backupPolicy', - models: { - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2000,23 +1585,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackupStorage', - models: { - dedicatedDatabaseBackupStorage: { - defaults: { - provider: '', - bucket: '', - region: '', - prefix: 'backups/', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2089,30 +1658,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBackup', - models: { - dedicatedDatabaseBackup: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - policyId: '', - trigger: 'manual', - type: 'full', - requestedType: '', - fallbackReason: '', - status: 'pending', - sizeBytes: 0, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2239,39 +1785,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseBranchList', - models: { - dedicatedDatabaseBranchList: { - defaults: { - total: 0, - }, - properties: { - branches: { - items: 'dedicatedDatabaseBranch', - }, - }, - }, - dedicatedDatabaseBranch: { - defaults: { - branchId: '', - branchName: '', - namespace: '', - expiresAt: 0, - host: '', - database: '', - username: '', - password: '', - ssl: false, - engine: '', - connectionString: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2355,63 +1869,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2485,63 +1943,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2601,26 +2003,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperation', - models: { - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2728,34 +2111,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseExecution', - models: { - dedicatedDatabaseExecution: { - defaults: { - rows: [], - rowCount: 0, - durationMs: 0, - truncated: false, - bytes: 0, - }, - properties: { - columns: { - items: 'dedicatedDatabaseExecutionColumn', - }, - }, - }, - dedicatedDatabaseExecutionColumn: { - defaults: { - name: '', - type: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2814,33 +2170,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseExtensions', - models: { - dedicatedDatabaseExtensions: { - defaults: { - installed: [], - available: [], - }, - properties: { - metadata: { - items: 'postgresExtension', - }, - }, - }, - postgresExtension: { - defaults: { - key: '', - name: '', - description: '', - category: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2916,63 +2246,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3049,63 +2323,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -3179,63 +2397,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3327,63 +2489,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3477,63 +2583,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3637,36 +2687,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3723,20 +2744,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePITRWindows', - models: { - dedicatedDatabasePITRWindows: { - defaults: { - earliest: '', - latest: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3793,28 +2801,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePooler', - models: { - dedicatedDatabasePooler: { - defaults: { - enabled: false, - mode: 'transaction', - maxConnections: 100, - defaultPoolSize: 20, - port: 6432, - readWriteSplitting: false, - poolerCpuRequest: '', - poolerCpuLimit: '', - poolerMemoryRequest: '', - poolerMemoryLimit: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3988,28 +2975,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabasePooler', - models: { - dedicatedDatabasePooler: { - defaults: { - enabled: false, - mode: 'transaction', - maxConnections: 100, - defaultPoolSize: 20, - port: 6432, - readWriteSplitting: false, - poolerCpuRequest: '', - poolerCpuLimit: '', - poolerMemoryRequest: '', - poolerMemoryLimit: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4066,35 +3032,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4210,35 +3148,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestorationList', - models: { - dedicatedDatabaseRestorationList: { - defaults: { - total: 0, - }, - properties: { - restorations: { - items: 'dedicatedDatabaseRestoration', - }, - }, - }, - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4355,25 +3265,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4449,25 +3341,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseRestoration', - models: { - dedicatedDatabaseRestoration: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - projectId: '', - type: 'backup', - status: 'pending', - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4522,50 +3396,7 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4643,62 +3474,6 @@ export class Postgresql { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index de5da33..eced57c 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Presences { @@ -91,33 +86,7 @@ export class Presences { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'presenceList', - models: { - presenceList: { - defaults: { - total: 0, - }, - properties: { - presences: { - items: 'presence', - }, - }, - }, - presence: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - source: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -174,23 +143,7 @@ export class Presences { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'presence', - models: { - presence: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - source: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -327,23 +280,7 @@ export class Presences { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'presence', - models: { - presence: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - source: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -489,23 +426,7 @@ export class Presences { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'presence', - models: { - presence: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - source: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 5ad53f3..7d59be7 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -48,77 +43,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -144,7 +69,7 @@ export class 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,passkey + * @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} @@ -156,7 +81,7 @@ export class 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,passkey + * @param {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise} @@ -219,77 +144,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -354,36 +209,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'keyList', - models: { - keyList: { - defaults: { - total: 0, - }, - properties: { - keys: { - items: 'key', - }, - }, - }, - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -466,26 +292,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'ephemeralKey', - models: { - ephemeralKey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -536,26 +343,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'key', - models: { - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -664,26 +452,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'key', - models: { - key: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - expire: '', - scopes: [], - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -789,77 +558,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -927,32 +626,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mockNumberList', - models: { - mockNumberList: { - defaults: { - total: 0, - }, - properties: { - mockNumbers: { - items: 'mockNumber', - }, - }, - }, - mockNumber: { - defaults: { - number: '', - otp: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1020,22 +694,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mockNumber', - models: { - mockNumber: { - defaults: { - number: '', - otp: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1088,22 +747,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mockNumber', - models: { - mockNumber: { - defaults: { - number: '', - otp: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1171,22 +815,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mockNumber', - models: { - mockNumber: { - defaults: { - number: '', - otp: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1306,19 +935,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2ProviderList', - models: { - oAuth2ProviderList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1591,77 +1208,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1746,22 +1293,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Amazon', - models: { - oAuth2Amazon: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1898,26 +1430,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Apple', - models: { - oAuth2Apple: { - defaults: { - $id: '', - enabled: false, - serviceId: '', - keyId: '', - teamId: '', - p8File: '', - nativeEnabled: false, - nativeClientIds: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2002,22 +1515,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Appwrite', - models: { - oAuth2Appwrite: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2130,24 +1628,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Auth0', - models: { - oAuth2Auth0: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2248,23 +1729,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Authentik', - models: { - oAuth2Authentik: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2349,22 +1814,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Autodesk', - models: { - oAuth2Autodesk: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2444,22 +1894,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Bitbucket', - models: { - oAuth2Bitbucket: { - defaults: { - $id: '', - enabled: false, - key: '', - secret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2544,22 +1979,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Bitly', - models: { - oAuth2Bitly: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2644,22 +2064,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Box', - models: { - oAuth2Box: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2744,22 +2149,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Cloudflare', - models: { - oAuth2Cloudflare: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2839,22 +2229,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Dailymotion', - models: { - oAuth2Dailymotion: { - defaults: { - $id: '', - enabled: false, - apiKey: '', - apiSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2955,23 +2330,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Discord', - models: { - oAuth2Discord: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3056,22 +2415,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Disqus', - models: { - oAuth2Disqus: { - defaults: { - $id: '', - enabled: false, - publicKey: '', - secretKey: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3151,22 +2495,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Dropbox', - models: { - oAuth2Dropbox: { - defaults: { - $id: '', - enabled: false, - appKey: '', - appSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3251,22 +2580,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Etsy', - models: { - oAuth2Etsy: { - defaults: { - $id: '', - enabled: false, - keyString: '', - sharedSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3346,22 +2660,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Facebook', - models: { - oAuth2Facebook: { - defaults: { - $id: '', - enabled: false, - appId: '', - appSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3446,22 +2745,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Figma', - models: { - oAuth2Figma: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3562,23 +2846,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2FusionAuth', - models: { - oAuth2FusionAuth: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3679,23 +2947,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Github', - models: { - oAuth2Github: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3796,23 +3048,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Gitlab', - models: { - oAuth2Gitlab: { - defaults: { - $id: '', - enabled: false, - applicationId: '', - secret: '', - endpoint: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3943,25 +3179,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Google', - models: { - oAuth2Google: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: ['consent'], - nativeEnabled: false, - nativeClientIds: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4046,22 +3264,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2HuggingFace', - models: { - oAuth2HuggingFace: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4162,23 +3365,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Kakao', - models: { - oAuth2Kakao: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4291,24 +3478,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Keycloak', - models: { - oAuth2Keycloak: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - endpoint: '', - realmName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4393,22 +3563,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Kick', - models: { - oAuth2Kick: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4497,22 +3652,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Linkedin', - models: { - oAuth2Linkedin: { - defaults: { - $id: '', - enabled: false, - clientId: '', - primaryClientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4625,24 +3765,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Microsoft', - models: { - oAuth2Microsoft: { - defaults: { - $id: '', - enabled: false, - applicationId: '', - applicationSecret: '', - prompt: [], - tenant: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4731,22 +3854,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Notion', - models: { - oAuth2Notion: { - defaults: { - $id: '', - enabled: false, - oauthClientId: '', - oauthClientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4916,27 +4024,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Oidc', - models: { - oAuth2Oidc: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - wellKnownURL: '', - authorizationURL: '', - tokenURL: '', - userInfoURL: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5067,25 +4155,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Okta', - models: { - oAuth2Okta: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - domain: '', - authorizationServerId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5170,22 +4240,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Paypal', - models: { - oAuth2Paypal: { - defaults: { - $id: '', - enabled: false, - clientId: '', - secretKey: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5270,22 +4325,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Paypal', - models: { - oAuth2Paypal: { - defaults: { - $id: '', - enabled: false, - clientId: '', - secretKey: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5370,22 +4410,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Podio', - models: { - oAuth2Podio: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5470,22 +4495,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Resend', - models: { - oAuth2Resend: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5586,23 +4596,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Salesforce', - models: { - oAuth2Salesforce: { - defaults: { - $id: '', - enabled: false, - customerKey: '', - customerSecret: '', - prompt: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5687,22 +4681,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Slack', - models: { - oAuth2Slack: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5787,22 +4766,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Spotify', - models: { - oAuth2Spotify: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5887,22 +4851,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Stripe', - models: { - oAuth2Stripe: { - defaults: { - $id: '', - enabled: false, - clientId: '', - apiSecretKey: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5987,22 +4936,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2TikTok', - models: { - oAuth2TikTok: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6091,22 +5025,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Tradeshift', - models: { - oAuth2Tradeshift: { - defaults: { - $id: '', - enabled: false, - oauth2ClientId: '', - oauth2ClientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6195,22 +5114,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Tradeshift', - models: { - oAuth2Tradeshift: { - defaults: { - $id: '', - enabled: false, - oauth2ClientId: '', - oauth2ClientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6295,22 +5199,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Twitch', - models: { - oAuth2Twitch: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6395,22 +5284,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Webflow', - models: { - oAuth2Webflow: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6495,22 +5369,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2WordPress', - models: { - oAuth2WordPress: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6595,22 +5454,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2X', - models: { - oAuth2X: { - defaults: { - $id: '', - enabled: false, - customerKey: '', - secretKey: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6695,22 +5539,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Yahoo', - models: { - oAuth2Yahoo: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6795,22 +5624,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Yandex', - models: { - oAuth2Yandex: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6911,23 +5725,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Zoho', - models: { - oAuth2Zoho: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - prompt: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7012,22 +5810,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'oAuth2Zoom', - models: { - oAuth2Zoom: { - defaults: { - $id: '', - enabled: false, - clientId: '', - clientSecret: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7299,19 +6082,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformList', - models: { - platformList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -7320,7 +6091,6 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. - * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} */ @@ -7328,7 +6098,6 @@ export class Project { platformId: string; name: string; applicationId: string; - fingerprints?: string[]; }): Promise; /** * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. @@ -7336,7 +6105,6 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. - * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -7345,25 +6113,14 @@ export class Project { platformId: string, name: string, applicationId: string, - fingerprints?: string[], ): Promise; createAndroidPlatform( paramsOrFirst: - | { - platformId: string; - name: string; - applicationId: string; - fingerprints?: string[]; - } + | { platformId: string; name: string; applicationId: string } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?] ): Promise { - let params: { - platformId: string; - name: string; - applicationId: string; - fingerprints?: string[]; - }; + let params: { platformId: string; name: string; applicationId: string }; if ( paramsOrFirst && @@ -7374,21 +6131,18 @@ export class Project { platformId: string; name: string; applicationId: string; - fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, - fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; - const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -7413,9 +6167,6 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } - if (typeof fingerprints !== 'undefined') { - apiPayload['fingerprints'] = fingerprints; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7424,33 +6175,15 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformAndroid', - models: { - platformAndroid: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - applicationId: '', - fingerprints: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. - * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} */ @@ -7458,15 +6191,13 @@ export class Project { platformId: string; name: string; applicationId: string; - fingerprints?: string[]; }): Promise; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. - * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -7475,25 +6206,14 @@ export class Project { platformId: string, name: string, applicationId: string, - fingerprints?: string[], ): Promise; updateAndroidPlatform( paramsOrFirst: - | { - platformId: string; - name: string; - applicationId: string; - fingerprints?: string[]; - } + | { platformId: string; name: string; applicationId: string } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?] ): Promise { - let params: { - platformId: string; - name: string; - applicationId: string; - fingerprints?: string[]; - }; + let params: { platformId: string; name: string; applicationId: string }; if ( paramsOrFirst && @@ -7504,21 +6224,18 @@ export class Project { platformId: string; name: string; applicationId: string; - fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, - fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; - const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -7543,9 +6260,6 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } - if (typeof fingerprints !== 'undefined') { - apiPayload['fingerprints'] = fingerprints; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -7554,24 +6268,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformAndroid', - models: { - platformAndroid: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - applicationId: '', - fingerprints: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -7668,23 +6365,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformApple', - models: { - platformApple: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - bundleIdentifier: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7781,23 +6462,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformApple', - models: { - platformApple: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - bundleIdentifier: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -7889,23 +6554,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformLinux', - models: { - platformLinux: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - packageName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7997,23 +6646,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformLinux', - models: { - platformLinux: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - packageName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -8105,23 +6738,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformWeb', - models: { - platformWeb: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - hostname: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8213,23 +6830,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformWeb', - models: { - platformWeb: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - hostname: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -8330,23 +6931,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformWindows', - models: { - platformWindows: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - packageIdentifierName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8447,23 +7032,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'platformWindows', - models: { - platformWindows: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - packageIdentifierName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -8664,19 +7233,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'policyList', - models: { - policyList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -8734,77 +7291,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8862,77 +7349,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8990,77 +7407,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9118,77 +7465,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9313,77 +7590,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9484,201 +7691,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. - * - * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasskeyPolicy(params: { rpId: string }): Promise; - /** - * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. - * - * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasskeyPolicy(rpId: string): Promise; - updatePasskeyPolicy( - paramsOrFirst: { rpId: string } | string, - ): Promise { - let params: { rpId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { rpId: string }; - } else { - params = { - rpId: paramsOrFirst as string, - }; - } - - const rpId = params.rpId; - if (typeof rpId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rpId"'); - } - const apiPath = '/project/policies/passkey'; - const apiPayload: Payload = {}; - if (typeof rpId !== 'undefined') { - apiPayload['rpId'] = rpId; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9736,77 +7749,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9866,77 +7809,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9994,77 +7867,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10145,216 +7948,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. - * - * @param {boolean} params.enabled - Enable password rotation. Disabled by default. - * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasswordRotationPolicy(params?: { - enabled?: boolean; - maxAge?: number; - }): Promise; - /** - * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. - * - * @param {boolean} enabled - Enable password rotation. Disabled by default. - * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasswordRotationPolicy( - enabled?: boolean, - maxAge?: number, - ): Promise; - updatePasswordRotationPolicy( - paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, - ...rest: [number?] - ): Promise { - let params: { enabled?: boolean; maxAge?: number }; - - if ( - (typeof paramsOrFirst === 'undefined' && rest.length === 0) || - (paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst)) - ) { - params = (paramsOrFirst || {}) as { - enabled?: boolean; - maxAge?: number; - }; - } else { - params = { - enabled: paramsOrFirst as boolean, - maxAge: rest[0] as number, - }; - } - - const enabled = params.enabled; - const maxAge = params.maxAge; - const apiPath = '/project/policies/password-rotation'; - const apiPayload: Payload = {}; - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof maxAge !== 'undefined') { - apiPayload['maxAge'] = maxAge; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10467,24 +8061,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'policyPasswordStrength', - models: { - policyPasswordStrength: { - defaults: { - $id: '', - min: 8, - uppercase: false, - lowercase: false, - number: false, - symbols: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10542,77 +8119,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10670,77 +8177,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10798,77 +8235,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10924,77 +8291,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11048,85 +8345,15 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -11136,7 +8363,6 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned - | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -11148,14 +8374,13 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail - | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -11166,7 +8391,6 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned - | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -11178,7 +8402,6 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail - | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -11188,7 +8411,6 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned - | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -11200,7 +8422,6 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail - | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -11316,77 +8537,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11467,77 +8618,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11720,77 +8801,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'project', - models: { - project: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - teamId: '', - region: 'fra', - smtpEnabled: false, - smtpSenderName: '', - smtpSenderEmail: '', - smtpReplyToName: '', - smtpReplyToEmail: '', - smtpHost: '', - smtpPort: 0, - smtpUsername: '', - smtpPassword: '', - smtpSecure: '', - pingCount: 0, - pingedAt: '', - labels: [], - status: 'active', - onboarding: [], - consoleAccessedAt: '', - }, - properties: { - authMethods: { - items: 'projectAuthMethod', - }, - services: { - items: 'projectService', - }, - protocols: { - items: 'projectProtocol', - }, - blocks: { - items: 'block', - }, - }, - }, - projectAuthMethod: { - defaults: { - enabled: true, - }, - }, - projectService: { - defaults: { - enabled: true, - }, - }, - projectProtocol: { - defaults: { - enabled: true, - }, - }, - block: { - defaults: { - $createdAt: '', - resourceType: '', - resourceId: '', - mode: 'full', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11912,36 +8923,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'emailTemplateList', - models: { - emailTemplateList: { - defaults: { - total: 0, - }, - properties: { - templates: { - items: 'emailTemplate', - }, - }, - }, - emailTemplate: { - defaults: { - templateId: '', - locale: '', - message: '', - senderName: '', - senderEmail: '', - replyToEmail: '', - replyToName: '', - subject: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -12110,26 +9092,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'emailTemplate', - models: { - emailTemplate: { - defaults: { - templateId: '', - locale: '', - message: '', - senderName: '', - senderEmail: '', - replyToEmail: '', - replyToName: '', - subject: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -12210,26 +9173,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'emailTemplate', - models: { - emailTemplate: { - defaults: { - templateId: '', - locale: '', - message: '', - senderName: '', - senderEmail: '', - replyToEmail: '', - replyToName: '', - subject: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -12297,36 +9241,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variableList', - models: { - variableList: { - defaults: { - total: 0, - }, - properties: { - variables: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -12437,26 +9352,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -12511,26 +9407,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -12635,26 +9512,7 @@ export class Project { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index 4c19007..b64891c 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -111,22 +106,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyInvalidation', - models: { - proxyInvalidation: { - defaults: { - domain: '', - type: '', - reference: '', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -194,41 +174,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRuleList', - models: { - proxyRuleList: { - defaults: { - total: 0, - }, - properties: { - rules: { - items: 'proxyRule', - }, - }, - }, - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -286,31 +232,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -401,31 +323,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -562,31 +460,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -675,31 +549,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -752,31 +602,7 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -882,30 +708,6 @@ export class Proxy { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'proxyRule', - models: { - proxyRule: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - domain: '', - type: '', - trigger: '', - redirectUrl: '', - redirectStatusCode: 301, - deploymentId: '', - deploymentResourceId: '', - deploymentVcsProviderBranch: '', - status: 'unverified', - logs: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 2456487..17ddc6b 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,7 +3,6 @@ import { Client, type Payload, UploadProgress, - applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -98,77 +97,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'siteList', - models: { - siteList: { - defaults: { - total: 0, - }, - properties: { - sites: { - items: 'site', - }, - }, - }, - site: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - enabled: true, - live: true, - logging: true, - framework: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - deploymentScreenshotLight: '', - deploymentScreenshotDark: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - timeout: 15, - installCommand: '', - buildCommand: '', - startCommand: '', - outputDirectory: '', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - buildRuntime: '', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -548,67 +477,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'site', - models: { - site: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - enabled: true, - live: true, - logging: true, - framework: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - deploymentScreenshotLight: '', - deploymentScreenshotDark: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - timeout: 15, - installCommand: '', - buildCommand: '', - startCommand: '', - outputDirectory: '', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - buildRuntime: '', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -659,44 +528,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'frameworkList', - models: { - frameworkList: { - defaults: { - total: 0, - }, - properties: { - frameworks: { - items: 'framework', - }, - }, - }, - framework: { - defaults: { - key: '', - name: '', - buildRuntime: '', - }, - properties: { - adapters: { - items: 'frameworkAdapter', - }, - }, - }, - frameworkAdapter: { - defaults: { - key: '', - installCommand: '', - buildCommand: '', - outputDirectory: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -764,32 +596,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'specificationList', - models: { - specificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'specification', - }, - }, - }, - specification: { - defaults: { - memory: 0, - cpus: 0, - enabled: false, - slug: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -840,67 +647,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'site', - models: { - site: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - enabled: true, - live: true, - logging: true, - framework: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - deploymentScreenshotLight: '', - deploymentScreenshotDark: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - timeout: 15, - installCommand: '', - buildCommand: '', - startCommand: '', - outputDirectory: '', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - buildRuntime: '', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1275,67 +1022,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'site', - models: { - site: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - enabled: true, - live: true, - logging: true, - framework: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - deploymentScreenshotLight: '', - deploymentScreenshotDark: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - timeout: 15, - installCommand: '', - buildCommand: '', - startCommand: '', - outputDirectory: '', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - buildRuntime: '', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1463,67 +1150,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'site', - models: { - site: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - enabled: true, - live: true, - logging: true, - framework: '', - deploymentRetention: 0, - deploymentId: '', - deploymentCreatedAt: '', - deploymentScreenshotLight: '', - deploymentScreenshotDark: '', - latestDeploymentId: '', - latestDeploymentCreatedAt: '', - latestDeploymentStatus: '', - scopes: [], - timeout: 15, - installCommand: '', - buildCommand: '', - startCommand: '', - outputDirectory: '', - installationId: '', - providerRepositoryId: '', - providerBranch: '', - providerRootDirectory: '', - providerSilentMode: false, - providerBranches: [], - providerPaths: [], - buildSpecification: 's-1vcpu-512mb', - runtimeSpecification: 's-1vcpu-512mb', - buildRuntime: '', - }, - properties: { - vars: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1625,54 +1252,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deploymentList', - models: { - deploymentList: { - defaults: { - total: 0, - }, - properties: { - deployments: { - items: 'deployment', - }, - }, - }, - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1899,44 +1479,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2107,44 +1650,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2259,44 +1765,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2370,44 +1839,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2666,44 +2098,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'deployment', - models: { - deployment: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - type: '', - resourceId: '', - resourceType: '', - entrypoint: '', - sourceSize: 0, - buildSize: 0, - totalSize: 0, - buildId: '', - activate: false, - screenshotLight: '', - screenshotDark: '', - buildLogs: '', - buildDuration: 0, - providerRepositoryName: '', - providerRepositoryOwner: '', - providerRepositoryUrl: '', - providerCommitHash: '', - providerCommitAuthorUrl: '', - providerCommitAuthor: '', - providerCommitMessage: '', - providerCommitUrl: '', - providerBranch: '', - providerBranchUrl: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2784,55 +2179,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'executionList', - models: { - executionList: { - defaults: { - total: 0, - }, - properties: { - executions: { - items: 'execution', - }, - }, - }, - execution: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - resourceId: '', - resourceType: 'functions', - deploymentId: '', - requestMethod: '', - requestPath: '', - responseStatusCode: 0, - responseBody: '', - logs: '', - errors: '', - duration: 0, - }, - properties: { - requestHeaders: { - items: 'headers', - }, - responseHeaders: { - items: 'headers', - }, - }, - }, - headers: { - defaults: { - name: '', - value: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2895,45 +2242,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'execution', - models: { - execution: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - resourceId: '', - resourceType: 'functions', - deploymentId: '', - requestMethod: '', - requestPath: '', - responseStatusCode: 0, - responseBody: '', - logs: '', - errors: '', - duration: 0, - }, - properties: { - requestHeaders: { - items: 'headers', - }, - responseHeaders: { - items: 'headers', - }, - }, - }, - headers: { - defaults: { - name: '', - value: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3075,36 +2384,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variableList', - models: { - variableList: { - defaults: { - total: 0, - }, - properties: { - variables: { - items: 'variable', - }, - }, - }, - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3230,26 +2510,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3317,26 +2578,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3452,26 +2694,7 @@ export class Sites { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'variable', - models: { - variable: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - value: '', - secret: false, - resourceType: '', - resourceId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index 5f299b7..eee28df 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,7 +3,6 @@ import { Client, type Payload, UploadProgress, - applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -94,42 +93,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'bucketList', - models: { - bucketList: { - defaults: { - total: 0, - }, - properties: { - buckets: { - items: 'bucket', - }, - }, - }, - bucket: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - fileSecurity: false, - name: '', - enabled: true, - maximumFileSize: 0, - allowedFileExtensions: [], - compression: '', - encryption: true, - antivirus: true, - transformations: true, - totalSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -332,32 +296,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'bucket', - models: { - bucket: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - fileSecurity: false, - name: '', - enabled: true, - maximumFileSize: 0, - allowedFileExtensions: [], - compression: '', - encryption: true, - antivirus: true, - transformations: true, - totalSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -412,32 +351,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'bucket', - models: { - bucket: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - fileSecurity: false, - name: '', - enabled: true, - maximumFileSize: 0, - allowedFileExtensions: [], - compression: '', - encryption: true, - antivirus: true, - transformations: true, - totalSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -640,32 +554,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'bucket', - models: { - bucket: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - fileSecurity: false, - name: '', - enabled: true, - maximumFileSize: 0, - allowedFileExtensions: [], - compression: '', - encryption: true, - antivirus: true, - transformations: true, - totalSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -823,44 +712,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'fileList', - models: { - fileList: { - defaults: { - total: 0, - }, - properties: { - files: { - items: 'file', - }, - }, - }, - file: { - defaults: { - $id: '', - bucketId: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - name: '', - folder: '', - key: '', - signature: '', - mimeType: '', - sizeOriginal: 0, - sizeActual: 0, - chunksTotal: 0, - chunksUploaded: 0, - encryption: false, - compression: 'none', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1082,34 +934,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'file', - models: { - file: { - defaults: { - $id: '', - bucketId: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - name: '', - folder: '', - key: '', - signature: '', - mimeType: '', - sizeOriginal: 0, - sizeActual: 0, - chunksTotal: 0, - chunksUploaded: 0, - encryption: false, - compression: 'none', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1213,34 +1038,7 @@ export class Storage { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'file', - models: { - file: { - defaults: { - $id: '', - bucketId: '', - $createdAt: '', - $updatedAt: '', - $permissions: [], - name: '', - folder: '', - key: '', - signature: '', - mimeType: '', - sizeOriginal: 0, - sizeActual: 0, - chunksTotal: 0, - chunksUploaded: 0, - encryption: false, - compression: 'none', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 50b9eed..bd8c228 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -93,64 +88,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseList', - models: { - databaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'database', - }, - }, - }, - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -284,54 +222,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -350,41 +241,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -452,34 +309,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transactionList', - models: { - transactionList: { - defaults: { - total: 0, - }, - properties: { - transactions: { - items: 'transaction', - }, - }, - }, - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -531,24 +361,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -605,24 +418,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -711,24 +507,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -859,24 +638,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -931,54 +693,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1107,54 +822,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1282,63 +950,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1395,45 +1007,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseMigrationList', - models: { - databaseMigrationList: { - defaults: { - total: 0, - }, - properties: { - migrations: { - items: 'databaseMigration', - }, - }, - }, - databaseMigration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - databaseId: '', - specification: '', - phase: 'pending', - attempt: 0, - lastError: '', - lagDocuments: 0, - changelogWatermark: 0, - verifiedAt: '', - cutoverAt: '', - soakUntil: '', - autoCutover: true, - cutoverRequested: false, - paused: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1531,35 +1105,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseMigration', - models: { - databaseMigration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - databaseId: '', - specification: '', - phase: 'pending', - attempt: 0, - lastError: '', - lagDocuments: 0, - changelogWatermark: 0, - verifiedAt: '', - cutoverAt: '', - soakUntil: '', - autoCutover: true, - cutoverRequested: false, - paused: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1632,35 +1178,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseMigration', - models: { - databaseMigration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - databaseId: '', - specification: '', - phase: 'pending', - attempt: 0, - lastError: '', - lagDocuments: 0, - changelogWatermark: 0, - verifiedAt: '', - cutoverAt: '', - soakUntil: '', - autoCutover: true, - cutoverRequested: false, - paused: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1809,35 +1327,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseMigration', - models: { - databaseMigration: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - databaseId: '', - specification: '', - phase: 'pending', - attempt: 0, - lastError: '', - lagDocuments: 0, - changelogWatermark: 0, - verifiedAt: '', - cutoverAt: '', - soakUntil: '', - autoCutover: true, - cutoverRequested: false, - paused: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1941,36 +1431,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2027,35 +1488,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2110,50 +1543,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2257,55 +1647,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'tableList', - models: { - tableList: { - defaults: { - total: 0, - }, - properties: { - tables: { - items: 'table', - }, - }, - }, - table: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - rowSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'columnIndex', - }, - }, - }, - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2474,45 +1816,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'table', - models: { - table: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - rowSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'columnIndex', - }, - }, - }, - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2582,45 +1886,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'table', - models: { - table: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - rowSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'columnIndex', - }, - }, - }, - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2762,45 +2028,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'table', - models: { - table: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - rowSecurity: false, - bytesMax: 0, - bytesUsed: 0, - }, - properties: { - indexes: { - items: 'columnIndex', - }, - }, - }, - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2973,19 +2201,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnList', - models: { - columnList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3157,24 +2373,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnBigint', - models: { - columnBigint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3350,24 +2549,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnBigint', - models: { - columnBigint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3508,24 +2690,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnBoolean', - models: { - columnBoolean: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3667,24 +2832,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnBoolean', - models: { - columnBoolean: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3823,24 +2971,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnDatetime', - models: { - columnDatetime: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3982,24 +3113,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnDatetime', - models: { - columnDatetime: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4139,25 +3253,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnEmail', - models: { - columnEmail: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'email', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4301,25 +3397,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnEmail', - models: { - columnEmail: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'email', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4474,25 +3552,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnEnum', - models: { - columnEnum: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'enum', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4653,25 +3713,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnEnum', - models: { - columnEnum: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'enum', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4843,24 +3885,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnFloat', - models: { - columnFloat: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5036,24 +4061,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnFloat', - models: { - columnFloat: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5226,24 +4234,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnInteger', - models: { - columnInteger: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5419,24 +4410,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnInteger', - models: { - columnInteger: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5576,25 +4550,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnIp', - models: { - columnIp: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'ip', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5738,25 +4694,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnIp', - models: { - columnIp: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'ip', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5882,24 +4820,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnLine', - models: { - columnLine: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6036,24 +4957,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnLine', - models: { - columnLine: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6206,24 +5110,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnLongtext', - models: { - columnLongtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6367,24 +5254,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnLongtext', - models: { - columnLongtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6537,24 +5407,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnMediumtext', - models: { - columnMediumtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6698,24 +5551,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnMediumtext', - models: { - columnMediumtext: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -6841,24 +5677,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnPoint', - models: { - columnPoint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -6995,24 +5814,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnPoint', - models: { - columnPoint: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7139,24 +5941,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnPolygon', - models: { - columnPolygon: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7293,24 +6078,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnPolygon', - models: { - columnPolygon: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7483,29 +6251,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnRelationship', - models: { - columnRelationship: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - relationType: '', - twoWay: false, - twoWayKey: '', - onDelete: 'restrict', - side: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -7627,29 +6373,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnRelationship', - models: { - columnRelationship: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - relationType: '', - twoWay: false, - twoWayKey: '', - onDelete: 'restrict', - side: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -7825,25 +6549,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnString', - models: { - columnString: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8000,25 +6706,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnString', - models: { - columnString: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8170,24 +6858,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnText', - models: { - columnText: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8331,24 +7002,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnText', - models: { - columnText: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8488,25 +7142,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnUrl', - models: { - columnUrl: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'url', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -8650,25 +7286,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnUrl', - models: { - columnUrl: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - format: 'url', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -8844,25 +7462,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnVarchar', - models: { - columnVarchar: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -9018,25 +7618,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnVarchar', - models: { - columnVarchar: { - defaults: { - key: '', - type: '', - error: '', - required: false, - $createdAt: '', - $updatedAt: '', - size: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -9365,37 +7947,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnIndexList', - models: { - columnIndexList: { - defaults: { - total: 0, - }, - properties: { - indexes: { - items: 'columnIndex', - }, - }, - }, - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -9557,27 +8109,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnIndex', - models: { - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -9662,27 +8194,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'columnIndex', - models: { - columnIndex: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - status: '', - error: '', - columns: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -9893,34 +8405,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'rowList', - models: { - rowList: { - defaults: { - total: 0, - }, - properties: { - rows: { - items: 'row', - }, - }, - }, - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -10076,24 +8561,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -10202,34 +8670,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'rowList', - models: { - rowList: { - defaults: { - total: 0, - }, - properties: { - rows: { - items: 'row', - }, - }, - }, - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -10340,34 +8781,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'rowList', - models: { - rowList: { - defaults: { - total: 0, - }, - properties: { - rows: { - items: 'row', - }, - }, - }, - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -10485,34 +8899,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'rowList', - models: { - rowList: { - defaults: { - total: 0, - }, - properties: { - rows: { - items: 'row', - }, - }, - }, - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -10618,34 +9005,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'rowList', - models: { - rowList: { - defaults: { - total: 0, - }, - properties: { - rows: { - items: 'row', - }, - }, - }, - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -10763,24 +9123,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -10934,24 +9277,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -11105,24 +9431,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11374,24 +9683,7 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -11536,23 +9828,6 @@ export class TablesDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'row', - models: { - row: { - defaults: { - $id: '', - $sequence: '', - $tableId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 931588e..821acb7 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Teams { @@ -91,33 +86,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'teamList', - models: { - teamList: { - defaults: { - total: 0, - }, - properties: { - teams: { - items: 'team', - }, - }, - }, - team: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -204,23 +173,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'team', - models: { - team: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -277,23 +230,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'team', - models: { - team: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -367,23 +304,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'team', - models: { - team: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -516,37 +437,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallationList', - models: { - appInstallationList: { - defaults: { - total: 0, - }, - properties: { - installations: { - items: 'appInstallation', - }, - }, - }, - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -636,27 +527,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -730,27 +601,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -845,27 +696,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'appInstallation', - models: { - appInstallation: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - appId: '', - teamId: '', - scopes: [], - authorizationDetails: [], - createdById: '', - createdByName: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1039,43 +870,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membershipList', - models: { - membershipList: { - defaults: { - total: 0, - }, - properties: { - memberships: { - items: 'membership', - }, - }, - }, - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1090,7 +885,6 @@ export class Teams { * * @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. - * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.email - Email of the new team member. * @param {string} params.userId - ID of the user to be added to a team. * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -1102,7 +896,6 @@ export class Teams { createMembership(params: { teamId: string; roles: string[]; - membershipId?: string; email?: string; userId?: string; phone?: string; @@ -1121,7 +914,6 @@ export class Teams { * * @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. - * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} email - Email of the new team member. * @param {string} userId - ID of the user to be added to a team. * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -1134,7 +926,6 @@ export class Teams { createMembership( teamId: string, roles: string[], - membershipId?: string, email?: string, userId?: string, phone?: string, @@ -1146,7 +937,6 @@ export class Teams { | { teamId: string; roles: string[]; - membershipId?: string; email?: string; userId?: string; phone?: string; @@ -1154,20 +944,11 @@ export class Teams { name?: string; } | string, - ...rest: [ - string[]?, - string?, - string?, - string?, - string?, - string?, - string?, - ] + ...rest: [string[]?, string?, string?, string?, string?, string?] ): Promise { let params: { teamId: string; roles: string[]; - membershipId?: string; email?: string; userId?: string; phone?: string; @@ -1183,7 +964,6 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; roles: string[]; - membershipId?: string; email?: string; userId?: string; phone?: string; @@ -1194,18 +974,16 @@ export class Teams { params = { teamId: paramsOrFirst as string, roles: rest[0] as string[], - membershipId: rest[1] as string, - email: rest[2] as string, - userId: rest[3] as string, - phone: rest[4] as string, - url: rest[5] as string, - name: rest[6] as string, + email: rest[1] as string, + userId: rest[2] as string, + phone: rest[3] as string, + url: rest[4] as string, + name: rest[5] as string, }; } const teamId = params.teamId; const roles = params.roles; - const membershipId = params.membershipId; const email = params.email; const userId = params.userId; const phone = params.phone; @@ -1222,9 +1000,6 @@ export class Teams { encodeURIComponent(String(teamId)), ); const apiPayload: Payload = {}; - if (typeof membershipId !== 'undefined') { - apiPayload['membershipId'] = membershipId; - } if (typeof email !== 'undefined') { apiPayload['email'] = email; } @@ -1251,33 +1026,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1351,33 +1100,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1468,33 +1191,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -1685,33 +1382,7 @@ export class Teams { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membership', - models: { - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index beab21b..796ccf9 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Tokens { @@ -113,35 +108,7 @@ export class Tokens { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'resourceTokenList', - models: { - resourceTokenList: { - defaults: { - total: 0, - }, - properties: { - tokens: { - items: 'resourceToken', - }, - }, - }, - resourceToken: { - defaults: { - $id: '', - $createdAt: '', - resourceId: '', - resourceType: '', - expire: '', - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -224,25 +191,7 @@ export class Tokens { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'resourceToken', - models: { - resourceToken: { - defaults: { - $id: '', - $createdAt: '', - resourceId: '', - resourceType: '', - expire: '', - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -297,25 +246,7 @@ export class Tokens { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'resourceToken', - models: { - resourceToken: { - defaults: { - $id: '', - $createdAt: '', - resourceId: '', - resourceType: '', - expire: '', - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -385,25 +316,7 @@ export class Tokens { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'resourceToken', - models: { - resourceToken: { - defaults: { - $id: '', - $createdAt: '', - resourceId: '', - resourceType: '', - expire: '', - secret: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 6652ee1..0210046 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -94,59 +89,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'userList', - models: { - userList: { - defaults: { - total: 0, - }, - properties: { - users: { - items: 'user', - }, - }, - }, - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -263,49 +206,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -417,49 +318,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -571,49 +430,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -692,39 +509,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'identityList', - models: { - identityList: { - defaults: { - total: 0, - }, - properties: { - identities: { - items: 'identity', - }, - }, - }, - identity: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - provider: '', - providerUid: '', - providerEmail: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - providerIdToken: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -892,49 +677,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1046,49 +789,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1299,49 +1000,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1509,49 +1168,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1680,49 +1297,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1779,49 +1354,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1947,49 +1480,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2070,49 +1561,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2194,19 +1643,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'jwt', - models: { - jwt: { - defaults: { - jwt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2287,49 +1724,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2431,43 +1826,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'membershipList', - models: { - membershipList: { - defaults: { - total: 0, - }, - properties: { - memberships: { - items: 'membership', - }, - }, - }, - membership: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - userName: '', - userEmail: '', - userPhone: '', - teamId: '', - teamName: '', - invited: '', - joined: '', - confirm: false, - mfa: false, - userAccessedAt: '', - roles: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2542,49 +1901,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2658,49 +1975,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2912,23 +2187,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaChallengeSecret', - models: { - mfaChallengeSecret: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - expire: '', - code: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2982,23 +2241,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaFactors', - models: { - mfaFactors: { - defaults: { - totp: false, - phone: false, - email: false, - recoveryCode: false, - custom: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3051,23 +2294,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaFactors', - models: { - mfaFactors: { - defaults: { - totp: false, - phone: false, - email: false, - recoveryCode: false, - custom: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3123,19 +2350,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3190,19 +2405,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3259,19 +2462,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3327,19 +2518,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3396,19 +2575,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3464,19 +2631,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'mfaRecoveryCodes', - models: { - mfaRecoveryCodes: { - defaults: { - recoveryCodes: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3550,408 +2705,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Get the list of verified passkeys registered by a user. - * - * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listPasskeys(params: { - userId: string; - queries?: string[]; - total?: boolean; - }): Promise; - /** - * Get the list of verified passkeys registered by a user. - * - * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt - * @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. - */ - listPasskeys( - userId: string, - queries?: string[], - total?: boolean, - ): Promise; - listPasskeys( - 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; - }; - } else { - params = { - userId: paramsOrFirst as string, - queries: rest[0] as string[], - total: rest[1] as boolean, - }; - } - - const userId = params.userId; - const queries = params.queries; - const total = params.total; - if (typeof userId === 'undefined' || userId === '') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - const apiPath = '/users/{userId}/passkeys'.replace( - '{userId}', - encodeURIComponent(String(userId)), - ); - 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', - }; - - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkeyList', - models: { - passkeyList: { - defaults: { - total: 0, - }, - properties: { - passkeys: { - items: 'passkey', - }, - }, - }, - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Get a verified passkey of a user by its unique ID. - * - * @param {string} params.userId - User ID. - * @param {string} params.passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getPasskey(params: { - userId: string; - passkeyId: string; - }): Promise; - /** - * Get a verified passkey of a user by its unique ID. - * - * @param {string} userId - User ID. - * @param {string} passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getPasskey(userId: string, passkeyId: string): Promise; - getPasskey( - paramsOrFirst: { userId: string; passkeyId: string } | string, - ...rest: [string?] - ): Promise { - let params: { userId: string; passkeyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - userId: string; - passkeyId: string; - }; - } else { - params = { - userId: paramsOrFirst as string, - passkeyId: rest[0] as string, - }; - } - - const userId = params.userId; - const passkeyId = params.passkeyId; - if (typeof userId === 'undefined' || userId === '') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - const apiPath = '/users/{userId}/passkeys/{passkeyId}' - .replace('{userId}', encodeURIComponent(String(userId))) - .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); - 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', - }; - - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkey', - models: { - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Rename a passkey of a user. - * - * @param {string} params.userId - User ID. - * @param {string} params.passkeyId - Passkey ID. - * @param {string} params.name - Passkey name. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePasskey(params: { - userId: string; - passkeyId: string; - name: string; - }): Promise; - /** - * Rename a passkey of a user. - * - * @param {string} userId - User ID. - * @param {string} passkeyId - Passkey ID. - * @param {string} name - Passkey name. Max length: 128 chars. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updatePasskey( - userId: string, - passkeyId: string, - name: string, - ): Promise; - updatePasskey( - paramsOrFirst: - { userId: string; passkeyId: string; name: string } | string, - ...rest: [string?, string?] - ): Promise { - let params: { userId: string; passkeyId: string; name: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - userId: string; - passkeyId: string; - name: string; - }; - } else { - params = { - userId: paramsOrFirst as string, - passkeyId: rest[0] as string, - name: rest[1] as string, - }; - } - - const userId = params.userId; - const passkeyId = params.passkeyId; - const name = params.name; - if (typeof userId === 'undefined' || userId === '') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/users/{userId}/passkeys/{passkeyId}' - .replace('{userId}', encodeURIComponent(String(userId))) - .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); - 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', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'passkey', - models: { - passkey: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - accessedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - * - * @param {string} params.userId - User ID. - * @param {string} params.passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; - /** - * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - * - * @param {string} userId - User ID. - * @param {string} passkeyId - Passkey ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deletePasskey(userId: string, passkeyId: string): Promise<{}>; - deletePasskey( - paramsOrFirst: { userId: string; passkeyId: string } | string, - ...rest: [string?] - ): Promise<{}> { - let params: { userId: string; passkeyId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - userId: string; - passkeyId: string; - }; - } else { - params = { - userId: paramsOrFirst as string, - passkeyId: rest[0] as string, - }; - } - - const userId = params.userId; - const passkeyId = params.passkeyId; - if (typeof userId === 'undefined' || userId === '') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof passkeyId === 'undefined' || passkeyId === '') { - throw new AppwriteException( - 'Missing required parameter: "passkeyId"', - ); - } - const apiPath = '/users/{userId}/passkeys/{passkeyId}' - .replace('{userId}', encodeURIComponent(String(userId))) - .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); - 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); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4030,49 +2784,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4149,49 +2861,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4386,57 +3056,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'sessionList', - models: { - sessionList: { - defaults: { - total: 0, - }, - properties: { - sessions: { - items: 'session', - }, - }, - }, - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4494,47 +3114,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'session', - models: { - session: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - userId: '', - expire: '', - provider: '', - providerUid: '', - providerAccessToken: '', - providerAccessTokenExpiry: '', - providerRefreshToken: '', - ip: '', - osCode: '', - osName: '', - osVersion: '', - clientType: '', - clientCode: '', - clientName: '', - clientVersion: '', - clientEngine: '', - clientEngineVersion: '', - deviceName: '', - deviceBrand: '', - deviceModel: '', - countryCode: '', - countryName: '', - current: false, - factors: [], - secret: '', - mfaUpdatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4729,49 +3309,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -4852,36 +3390,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'targetList', - models: { - targetList: { - defaults: { - total: 0, - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5023,26 +3532,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'target', - models: { - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5110,26 +3600,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'target', - models: { - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -5245,26 +3716,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'target', - models: { - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5414,24 +3866,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'token', - models: { - token: { - defaults: { - $id: '', - $createdAt: '', - userId: '', - secret: '', - expire: '', - phrase: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -5513,49 +3948,7 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -5637,48 +4030,6 @@ export class Users { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'user', - models: { - user: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - registration: '', - status: true, - labels: [], - passwordUpdate: '', - email: '', - phone: '', - emailVerification: false, - phoneVerification: false, - mfa: false, - accessedAt: '', - }, - properties: { - targets: { - items: 'target', - }, - }, - }, - target: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - userId: '', - providerType: '', - identifier: '', - expired: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 31db5a2..55871ee 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -77,64 +72,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseList', - models: { - databaseList: { - defaults: { - total: 0, - }, - properties: { - databases: { - items: 'database', - }, - }, - }, - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -268,54 +206,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -334,41 +225,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseSpecificationList', - models: { - dedicatedDatabaseSpecificationList: { - defaults: { - total: 0, - }, - properties: { - specifications: { - items: 'dedicatedDatabaseSpecification', - }, - }, - }, - dedicatedDatabaseSpecification: { - defaults: { - slug: '', - name: '', - price: 0, - storageOverageRate: 0, - bandwidthOverageRate: 0, - replicaRate: 0, - pitrRate: 0, - cpu: 0, - memory: 0, - maxConnections: 0, - includedStorage: 0, - includedBandwidth: 0, - enabled: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -436,34 +293,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transactionList', - models: { - transactionList: { - defaults: { - total: 0, - }, - properties: { - transactions: { - items: 'transaction', - }, - }, - }, - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -515,24 +345,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -589,24 +402,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -695,24 +491,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -843,24 +622,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'transaction', - models: { - transaction: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - status: 'pending', - operations: 0, - expiresAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -915,54 +677,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1094,54 +809,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'database', - models: { - database: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - enabled: true, - type: 'legacy', - }, - properties: { - policies: { - items: 'backupPolicy', - }, - archives: { - items: 'backupArchive', - }, - }, - }, - backupPolicy: { - defaults: { - $id: '', - name: '', - $createdAt: '', - $updatedAt: '', - retention: 1, - schedule: '0 * * * *', - type: 'full', - enabled: false, - }, - }, - backupArchive: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - policyId: '', - status: '', - migrationId: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -1299,55 +967,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'vectorsdbCollectionList', - models: { - vectorsdbCollectionList: { - defaults: { - total: 0, - }, - properties: { - collections: { - items: 'vectorsdbCollection', - }, - }, - }, - vectorsdbCollection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - dimension: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1501,45 +1121,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'vectorsdbCollection', - models: { - vectorsdbCollection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - dimension: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -1615,45 +1197,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'vectorsdbCollection', - models: { - vectorsdbCollection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - dimension: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -1801,45 +1345,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'vectorsdbCollection', - models: { - vectorsdbCollection: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - databaseId: '', - name: '', - enabled: true, - documentSecurity: false, - bytesMax: 0, - bytesUsed: 0, - dimension: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2048,34 +1554,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -2244,24 +1723,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2378,34 +1840,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -2524,34 +1959,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -2675,34 +2083,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -2814,34 +2195,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('delete', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -2979,34 +2333,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'documentList', - models: { - documentList: { - defaults: { - total: 0, - }, - properties: { - documents: { - items: 'document', - }, - }, - }, - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -3135,24 +2462,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3321,24 +2631,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -3507,24 +2800,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'document', - models: { - document: { - defaults: { - $id: '', - $sequence: '', - $collectionId: '', - $databaseId: '', - $createdAt: '', - $updatedAt: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } /** @@ -3749,36 +3025,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'indexList', - models: { - indexList: { - defaults: { - total: 0, - }, - properties: { - indexes: { - items: 'index', - }, - }, - }, - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -3944,26 +3191,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4052,26 +3280,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'index', - models: { - index: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - key: '', - type: '', - error: '', - attributes: [], - lengths: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4235,63 +3444,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabase', - models: { - dedicatedDatabase: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - projectId: '', - name: '', - version: '', - specification: '', - backend: '', - hostname: '', - connectionUser: '', - connectionPassword: '', - connectionString: '', - ssl: false, - status: 'provisioning', - containerStatus: '', - lifecycleState: '', - idleTimeoutMinutes: 15, - cpu: 500, - memory: 512, - storage: 10, - storageStatus: 'idle', - storageTargetGb: 0, - storageClass: 'ssd', - storageMaxGb: 0, - nodePool: '', - replicas: 0, - syncMode: '', - networkMaxConnections: 100, - networkIdleTimeoutSeconds: 900, - networkIPAllowlist: [], - backupEnabled: true, - pitr: true, - pitrRetentionDays: 7, - storageAutoscaling: true, - storageAutoscalingThresholdPercent: 85, - storageAutoscalingMaxGb: 0, - maintenanceWindowDay: 'sun', - maintenanceWindowHourUtc: 3, - metricsEnabled: false, - sqlApiEnabled: true, - sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], - sqlApiMaxRows: 10000, - sqlApiMaxBytes: 10485760, - sqlApiTimeoutSeconds: 30, - error: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -4395,36 +3548,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseOperationList', - models: { - dedicatedDatabaseOperationList: { - defaults: { - total: 0, - }, - properties: { - operations: { - items: 'dedicatedDatabaseOperation', - }, - }, - }, - dedicatedDatabaseOperation: { - defaults: { - $id: '', - $createdAt: '', - databaseId: '', - type: '', - status: '', - attempts: 0, - errorCode: '', - errorMessage: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4481,35 +3605,7 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'dedicatedDatabaseReplicas', - models: { - dedicatedDatabaseReplicas: { - defaults: { - replicas: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - members: { - items: 'dedicatedDatabaseMember', - }, - }, - }, - dedicatedDatabaseMember: { - defaults: { - $id: '', - role: 'unknown', - status: '', - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -4564,49 +3660,6 @@ export class VectorsDB { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'databaseStatus', - models: { - databaseStatus: { - defaults: { - health: 'unknown', - ready: false, - engine: 'postgresql', - version: '', - uptime: 0, - syncMode: 'async', - syncDegraded: false, - syncAcknowledgements: 0, - syncStandbyCount: 0, - }, - properties: { - replicas: { - items: 'databaseStatusReplica', - }, - volumes: { - items: 'databaseStatusVolume', - }, - }, - }, - databaseStatusReplica: { - defaults: { - index: 0, - role: 'unknown', - healthy: false, - }, - }, - databaseStatusVolume: { - defaults: { - path: '', - usedPercent: '0%', - available: '0GB', - mounted: false, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } } diff --git a/src/services/waf.ts b/src/services/waf.ts deleted file mode 100644 index ae34e19..0000000 --- a/src/services/waf.ts +++ /dev/null @@ -1,2414 +0,0 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; -import type { Models } from '../models'; - -export class Waf { - client: Client; - - constructor(client: Client) { - this.client = client; - } - - /** - * List WAF rules for the current project. - * - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listRules(params?: { - queries?: string[]; - search?: string; - total?: boolean; - }): Promise; - /** - * List WAF rules for the current project. - * - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listRules( - queries?: string[], - search?: string, - total?: boolean, - ): Promise; - listRules( - paramsOrFirst?: - { queries?: string[]; search?: string; total?: boolean } | string[], - ...rest: [string?, boolean?] - ): Promise { - let params: { queries?: string[]; search?: string; total?: boolean }; - - if ( - (typeof paramsOrFirst === 'undefined' && rest.length === 0) || - (paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst)) - ) { - params = (paramsOrFirst || {}) as { - queries?: string[]; - search?: string; - total?: boolean; - }; - } else { - params = { - queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean, - }; - } - - const queries = params.queries; - const search = params.search; - const total = params.total; - const apiPath = '/waf/rules'; - const apiPayload: Payload = {}; - if (typeof queries !== 'undefined') { - apiPayload['queries'] = queries; - } - if (typeof search !== 'undefined') { - apiPayload['search'] = search; - } - if (typeof total !== 'undefined') { - apiPayload['total'] = total; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleList', - models: { - wafRuleList: { - defaults: { - total: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.name - Rule name. - * @param {string} params.resourceId - Resource identifier. Leave empty for the API resource type. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - createBypassRule(params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} name - Rule name. - * @param {string} resourceId - Resource identifier. Leave empty for the API resource type. - * @param {string} description - Optional description for the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to create the rule in a disabled state. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createBypassRule( - ruleId: string, - resourceType: string, - name: string, - resourceId?: string, - description?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - createBypassRule( - paramsOrFirst: - | { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - name: rest[1] as string, - resourceId: rest[2] as string, - description: rest[3] as string, - priority: rest[4] as number, - enabled: rest[5] as boolean, - conditions: rest[6] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const name = params.name; - const resourceId = params.resourceId; - const description = params.description; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - if (typeof resourceType === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "resourceType"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/waf/rules/bypass'; - const apiPayload: Payload = {}; - if (typeof ruleId !== 'undefined') { - apiPayload['ruleId'] = ruleId; - } - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleBypass', - models: { - wafRuleBypass: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.name - Rule name. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to disable the rule. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateBypassRule(params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} name - Rule name. - * @param {string} description - Optional description for the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to disable the rule. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateBypassRule( - ruleId: string, - resourceType?: string, - resourceId?: string, - name?: string, - description?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - updateBypassRule( - paramsOrFirst: - | { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - resourceId: rest[1] as string, - name: rest[2] as string, - description: rest[3] as string, - priority: rest[4] as number, - enabled: rest[5] as boolean, - conditions: rest[6] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const resourceId = params.resourceId; - const name = params.name; - const description = params.description; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/bypass/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleBypass', - models: { - wafRuleBypass: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.name - Rule name. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.description - Optional description for the rule. - * @param {string} params.challengeType - Challenge type enforced by the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. - * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. - * @throws {AppwriteException} - * @returns {Promise} - */ - createChallengeRule(params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }): Promise; - /** - * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} name - Rule name. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} description - Optional description for the rule. - * @param {string} challengeType - Challenge type enforced by the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to create the rule in a disabled state. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. - * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createChallengeRule( - ruleId: string, - resourceType: string, - name: string, - resourceId?: string, - description?: string, - challengeType?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - difficulty?: number, - ttl?: number, - ): Promise; - createChallengeRule( - paramsOrFirst: - | { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - number?, - number?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - name: rest[1] as string, - resourceId: rest[2] as string, - description: rest[3] as string, - challengeType: rest[4] as string, - priority: rest[5] as number, - enabled: rest[6] as boolean, - conditions: rest[7] as string[], - difficulty: rest[8] as number, - ttl: rest[9] as number, - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const name = params.name; - const resourceId = params.resourceId; - const description = params.description; - const challengeType = params.challengeType; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - const difficulty = params.difficulty; - const ttl = params.ttl; - if (typeof ruleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - if (typeof resourceType === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "resourceType"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/waf/rules/challenge'; - const apiPayload: Payload = {}; - if (typeof ruleId !== 'undefined') { - apiPayload['ruleId'] = ruleId; - } - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof challengeType !== 'undefined') { - apiPayload['challengeType'] = challengeType; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - if (typeof difficulty !== 'undefined') { - apiPayload['difficulty'] = difficulty; - } - if (typeof ttl !== 'undefined') { - apiPayload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleChallenge', - models: { - wafRuleChallenge: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - challengeType: 'compute', - difficulty: 3, - ttl: 1800, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.name - Rule name. - * @param {string} params.description - Optional description for the rule. - * @param {string} params.challengeType - Challenge type enforced by the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to disable the rule. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. - * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateChallengeRule(params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }): Promise; - /** - * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} name - Rule name. - * @param {string} description - Optional description for the rule. - * @param {string} challengeType - Challenge type enforced by the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to disable the rule. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. - * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateChallengeRule( - ruleId: string, - resourceType?: string, - resourceId?: string, - name?: string, - description?: string, - challengeType?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - difficulty?: number, - ttl?: number, - ): Promise; - updateChallengeRule( - paramsOrFirst: - | { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - number?, - number?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - challengeType?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - difficulty?: number; - ttl?: number; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - resourceId: rest[1] as string, - name: rest[2] as string, - description: rest[3] as string, - challengeType: rest[4] as string, - priority: rest[5] as number, - enabled: rest[6] as boolean, - conditions: rest[7] as string[], - difficulty: rest[8] as number, - ttl: rest[9] as number, - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const resourceId = params.resourceId; - const name = params.name; - const description = params.description; - const challengeType = params.challengeType; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - const difficulty = params.difficulty; - const ttl = params.ttl; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/challenge/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof challengeType !== 'undefined') { - apiPayload['challengeType'] = challengeType; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - if (typeof difficulty !== 'undefined') { - apiPayload['difficulty'] = difficulty; - } - if (typeof ttl !== 'undefined') { - apiPayload['ttl'] = ttl; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleChallenge', - models: { - wafRuleChallenge: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - challengeType: 'compute', - difficulty: 3, - ttl: 1800, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.name - Rule name. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - createDenyRule(params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} name - Rule name. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} description - Optional description for the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to create the rule in a disabled state. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createDenyRule( - ruleId: string, - resourceType: string, - name: string, - resourceId?: string, - description?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - createDenyRule( - paramsOrFirst: - | { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType: string; - name: string; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - name: rest[1] as string, - resourceId: rest[2] as string, - description: rest[3] as string, - priority: rest[4] as number, - enabled: rest[5] as boolean, - conditions: rest[6] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const name = params.name; - const resourceId = params.resourceId; - const description = params.description; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - if (typeof resourceType === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "resourceType"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/waf/rules/deny'; - const apiPayload: Payload = {}; - if (typeof ruleId !== 'undefined') { - apiPayload['ruleId'] = ruleId; - } - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleDeny', - models: { - wafRuleDeny: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.name - Rule name. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to disable the rule. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDenyRule(params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} name - Rule name. - * @param {string} description - Optional description for the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to disable the rule. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateDenyRule( - ruleId: string, - resourceType?: string, - resourceId?: string, - name?: string, - description?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - updateDenyRule( - paramsOrFirst: - | { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - resourceId: rest[1] as string, - name: rest[2] as string, - description: rest[3] as string, - priority: rest[4] as number, - enabled: rest[5] as boolean, - conditions: rest[6] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const resourceId = params.resourceId; - const name = params.name; - const description = params.description; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/deny/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleDeny', - models: { - wafRuleDeny: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.name - Rule name. - * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. - * @param {number} params.interval - Interval in seconds used for rate limiting. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.description - Optional description for the rule. - * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. - * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. - * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - createRateLimitRule(params: { - ruleId: string; - resourceType: string; - name: string; - limit: number; - interval: number; - resourceId?: string; - description?: string; - key?: string; - strategy?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} name - Rule name. - * @param {number} limit - Maximum number of matching requests allowed in the configured interval. - * @param {number} interval - Interval in seconds used for rate limiting. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} description - Optional description for the rule. - * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. - * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. - * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to create the rule in a disabled state. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createRateLimitRule( - ruleId: string, - resourceType: string, - name: string, - limit: number, - interval: number, - resourceId?: string, - description?: string, - key?: string, - strategy?: string, - maxBucketSize?: number, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - createRateLimitRule( - paramsOrFirst: - | { - ruleId: string; - resourceType: string; - name: string; - limit: number; - interval: number; - resourceId?: string; - description?: string; - key?: string; - strategy?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - number?, - number?, - string?, - string?, - string?, - string?, - number?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType: string; - name: string; - limit: number; - interval: number; - resourceId?: string; - description?: string; - key?: string; - strategy?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType: string; - name: string; - limit: number; - interval: number; - resourceId?: string; - description?: string; - key?: string; - strategy?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - name: rest[1] as string, - limit: rest[2] as number, - interval: rest[3] as number, - resourceId: rest[4] as string, - description: rest[5] as string, - key: rest[6] as string, - strategy: rest[7] as string, - maxBucketSize: rest[8] as number, - priority: rest[9] as number, - enabled: rest[10] as boolean, - conditions: rest[11] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const name = params.name; - const limit = params.limit; - const interval = params.interval; - const resourceId = params.resourceId; - const description = params.description; - const key = params.key; - const strategy = params.strategy; - const maxBucketSize = params.maxBucketSize; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - if (typeof resourceType === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "resourceType"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof limit === 'undefined') { - throw new AppwriteException('Missing required parameter: "limit"'); - } - if (typeof interval === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "interval"', - ); - } - const apiPath = '/waf/rules/rate-limit'; - const apiPayload: Payload = {}; - if (typeof ruleId !== 'undefined') { - apiPayload['ruleId'] = ruleId; - } - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof limit !== 'undefined') { - apiPayload['limit'] = limit; - } - if (typeof interval !== 'undefined') { - apiPayload['interval'] = interval; - } - if (typeof key !== 'undefined') { - apiPayload['key'] = key; - } - if (typeof strategy !== 'undefined') { - apiPayload['strategy'] = strategy; - } - if (typeof maxBucketSize !== 'undefined') { - apiPayload['maxBucketSize'] = maxBucketSize; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleRateLimit', - models: { - wafRuleRateLimit: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - limit: 100, - interval: 3600, - key: 'ip', - strategy: 'fixedWindow', - maxBucketSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.name - Rule name. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. - * @param {number} params.interval - Interval in seconds used for rate limiting. - * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. - * @param {number} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to disable the rule. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateRateLimitRule(params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - limit?: number; - interval?: number; - key?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} name - Rule name. - * @param {string} description - Optional description for the rule. - * @param {number} limit - Maximum number of matching requests allowed in the configured interval. - * @param {number} interval - Interval in seconds used for rate limiting. - * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. - * @param {number} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to disable the rule. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateRateLimitRule( - ruleId: string, - resourceType?: string, - resourceId?: string, - name?: string, - description?: string, - limit?: number, - interval?: number, - key?: string, - maxBucketSize?: number, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - updateRateLimitRule( - paramsOrFirst: - | { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - limit?: number; - interval?: number; - key?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - number?, - number?, - string?, - number?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - limit?: number; - interval?: number; - key?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - limit?: number; - interval?: number; - key?: string; - maxBucketSize?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - resourceId: rest[1] as string, - name: rest[2] as string, - description: rest[3] as string, - limit: rest[4] as number, - interval: rest[5] as number, - key: rest[6] as string, - maxBucketSize: rest[7] as number, - priority: rest[8] as number, - enabled: rest[9] as boolean, - conditions: rest[10] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const resourceId = params.resourceId; - const name = params.name; - const description = params.description; - const limit = params.limit; - const interval = params.interval; - const key = params.key; - const maxBucketSize = params.maxBucketSize; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof limit !== 'undefined') { - apiPayload['limit'] = limit; - } - if (typeof interval !== 'undefined') { - apiPayload['interval'] = interval; - } - if (typeof key !== 'undefined') { - apiPayload['key'] = key; - } - if (typeof maxBucketSize !== 'undefined') { - apiPayload['maxBucketSize'] = maxBucketSize; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleRateLimit', - models: { - wafRuleRateLimit: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - limit: 100, - interval: 3600, - key: 'ip', - strategy: 'fixedWindow', - maxBucketSize: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.name - Rule name. - * @param {string} params.location - Location used for redirect responses. - * @param {number} params.statusCode - Integer status code used for redirect responses. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.description - Optional description for the rule. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - createRedirectRule(params: { - ruleId: string; - resourceType: string; - name: string; - location: string; - statusCode: number; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} name - Rule name. - * @param {string} location - Location used for redirect responses. - * @param {number} statusCode - Integer status code used for redirect responses. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} description - Optional description for the rule. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to create the rule in a disabled state. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createRedirectRule( - ruleId: string, - resourceType: string, - name: string, - location: string, - statusCode: number, - resourceId?: string, - description?: string, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - createRedirectRule( - paramsOrFirst: - | { - ruleId: string; - resourceType: string; - name: string; - location: string; - statusCode: number; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - number?, - string?, - string?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType: string; - name: string; - location: string; - statusCode: number; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType: string; - name: string; - location: string; - statusCode: number; - resourceId?: string; - description?: string; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - name: rest[1] as string, - location: rest[2] as string, - statusCode: rest[3] as number, - resourceId: rest[4] as string, - description: rest[5] as string, - priority: rest[6] as number, - enabled: rest[7] as boolean, - conditions: rest[8] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const name = params.name; - const location = params.location; - const statusCode = params.statusCode; - const resourceId = params.resourceId; - const description = params.description; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - if (typeof resourceType === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "resourceType"', - ); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof location === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "location"', - ); - } - if (typeof statusCode === 'undefined') { - throw new AppwriteException( - 'Missing required parameter: "statusCode"', - ); - } - const apiPath = '/waf/rules/redirect'; - const apiPayload: Payload = {}; - if (typeof ruleId !== 'undefined') { - apiPayload['ruleId'] = ruleId; - } - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof location !== 'undefined') { - apiPayload['location'] = location; - } - if (typeof statusCode !== 'undefined') { - apiPayload['statusCode'] = statusCode; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleRedirect', - models: { - wafRuleRedirect: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - location: '/', - statusCode: 302, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} params.ruleId - Rule ID. - * @param {string} params.resourceType - Resource type the rule applies to. - * @param {string} params.resourceId - Resource identifier. Required for functions and sites. - * @param {string} params.name - Rule name. - * @param {string} params.description - Optional description for the rule. - * @param {string} params.location - Location used for redirect responses. - * @param {number} params.statusCode - Integer status code used for redirect responses. - * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} params.enabled - Set to false to disable the rule. - * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateRedirectRule(params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - location?: string; - statusCode?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }): Promise; - /** - * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. - * - * - * @param {string} ruleId - Rule ID. - * @param {string} resourceType - Resource type the rule applies to. - * @param {string} resourceId - Resource identifier. Required for functions and sites. - * @param {string} name - Rule name. - * @param {string} description - Optional description for the rule. - * @param {string} location - Location used for redirect responses. - * @param {number} statusCode - Integer status code used for redirect responses. - * @param {number} priority - Evaluation priority. Lower numbers run earlier. - * @param {boolean} enabled - Set to false to disable the rule. - * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateRedirectRule( - ruleId: string, - resourceType?: string, - resourceId?: string, - name?: string, - description?: string, - location?: string, - statusCode?: number, - priority?: number, - enabled?: boolean, - conditions?: string[], - ): Promise; - updateRedirectRule( - paramsOrFirst: - | { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - location?: string; - statusCode?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - } - | string, - ...rest: [ - string?, - string?, - string?, - string?, - string?, - number?, - number?, - boolean?, - string[]?, - ] - ): Promise { - let params: { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - location?: string; - statusCode?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { - ruleId: string; - resourceType?: string; - resourceId?: string; - name?: string; - description?: string; - location?: string; - statusCode?: number; - priority?: number; - enabled?: boolean; - conditions?: string[]; - }; - } else { - params = { - ruleId: paramsOrFirst as string, - resourceType: rest[0] as string, - resourceId: rest[1] as string, - name: rest[2] as string, - description: rest[3] as string, - location: rest[4] as string, - statusCode: rest[5] as number, - priority: rest[6] as number, - enabled: rest[7] as boolean, - conditions: rest[8] as string[], - }; - } - - const ruleId = params.ruleId; - const resourceType = params.resourceType; - const resourceId = params.resourceId; - const name = params.name; - const description = params.description; - const location = params.location; - const statusCode = params.statusCode; - const priority = params.priority; - const enabled = params.enabled; - const conditions = params.conditions; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/redirect/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - if (typeof resourceType !== 'undefined') { - apiPayload['resourceType'] = resourceType; - } - if (typeof resourceId !== 'undefined') { - apiPayload['resourceId'] = resourceId; - } - if (typeof name !== 'undefined') { - apiPayload['name'] = name; - } - if (typeof description !== 'undefined') { - apiPayload['description'] = description; - } - if (typeof location !== 'undefined') { - apiPayload['location'] = location; - } - if (typeof statusCode !== 'undefined') { - apiPayload['statusCode'] = statusCode; - } - if (typeof priority !== 'undefined') { - apiPayload['priority'] = priority; - } - if (typeof enabled !== 'undefined') { - apiPayload['enabled'] = enabled; - } - if (typeof conditions !== 'undefined') { - apiPayload['conditions'] = conditions; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'wafRuleRedirect', - models: { - wafRuleRedirect: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - description: '', - teamId: '', - projectId: '', - resourceType: 'api', - resourceId: '', - priority: 0, - enabled: true, - conditions: [], - config: [], - location: '/', - statusCode: 302, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); - } - - /** - * Get a WAF rule by its ID. - * - * - * @param {string} params.ruleId - Rule ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getRule(params: { - ruleId: string; - }): Promise< - | Models.WafRuleBypass - | Models.WafRuleDeny - | Models.WafRuleChallenge - | Models.WafRuleRateLimit - | Models.WafRuleRedirect - >; - /** - * Get a WAF rule by its ID. - * - * - * @param {string} ruleId - Rule ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getRule( - ruleId: string, - ): Promise< - | Models.WafRuleBypass - | Models.WafRuleDeny - | Models.WafRuleChallenge - | Models.WafRuleRateLimit - | Models.WafRuleRedirect - >; - getRule( - paramsOrFirst: { ruleId: string } | string, - ): Promise< - | Models.WafRuleBypass - | Models.WafRuleDeny - | Models.WafRuleChallenge - | Models.WafRuleRateLimit - | Models.WafRuleRedirect - > { - let params: { ruleId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { ruleId: string }; - } else { - params = { - ruleId: paramsOrFirst as string, - }; - } - - const ruleId = params.ruleId; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - accept: 'application/json', - }; - - return this.client.call('get', uri, apiHeaders, apiPayload); - } - - /** - * Delete a WAF rule. - * - * - * @param {string} params.ruleId - Rule ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteRule(params: { ruleId: string }): Promise<{}>; - /** - * Delete a WAF rule. - * - * - * @param {string} ruleId - Rule ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteRule(ruleId: string): Promise<{}>; - deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { - let params: { ruleId: string }; - - if ( - paramsOrFirst && - typeof paramsOrFirst === 'object' && - !Array.isArray(paramsOrFirst) - ) { - params = (paramsOrFirst || {}) as { ruleId: string }; - } else { - params = { - ruleId: paramsOrFirst as string, - }; - } - - const ruleId = params.ruleId; - if (typeof ruleId === 'undefined' || ruleId === '') { - throw new AppwriteException('Missing required parameter: "ruleId"'); - } - const apiPath = '/waf/rules/{ruleId}'.replace( - '{ruleId}', - encodeURIComponent(String(ruleId)), - ); - const apiPayload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'X-Appwrite-Project': this.client.config.project, - 'content-type': 'application/json', - accept: 'application/json', - }; - - return this.client.call('delete', uri, apiHeaders, apiPayload); - } -} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 8d41212..0a61f59 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,9 +1,4 @@ -import { - AppwriteException, - Client, - type Payload, - applyDefaults, -} from '../client'; +import { AppwriteException, Client, type Payload } from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -75,41 +70,7 @@ export class Webhooks { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'webhookList', - models: { - webhookList: { - defaults: { - total: 0, - }, - properties: { - webhooks: { - items: 'webhook', - }, - }, - }, - webhook: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - url: '', - events: [], - tls: true, - authUsername: '', - authPassword: '', - secret: '', - enabled: true, - logs: '', - attempts: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -121,8 +82,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise} @@ -147,8 +108,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise} @@ -292,31 +253,7 @@ export class Webhooks { accept: 'application/json', }; - const request = this.client.call('post', uri, apiHeaders, apiPayload); - const defaults = { - root: 'webhook', - models: { - webhook: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - url: '', - events: [], - tls: true, - authUsername: '', - authPassword: '', - secret: '', - enabled: true, - logs: '', - attempts: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('post', uri, apiHeaders, apiPayload); } /** @@ -371,31 +308,7 @@ export class Webhooks { accept: 'application/json', }; - const request = this.client.call('get', uri, apiHeaders, apiPayload); - const defaults = { - root: 'webhook', - models: { - webhook: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - url: '', - events: [], - tls: true, - authUsername: '', - authPassword: '', - secret: '', - enabled: true, - logs: '', - attempts: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('get', uri, apiHeaders, apiPayload); } /** @@ -407,8 +320,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise} */ @@ -431,8 +344,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -565,31 +478,7 @@ export class Webhooks { accept: 'application/json', }; - const request = this.client.call('put', uri, apiHeaders, apiPayload); - const defaults = { - root: 'webhook', - models: { - webhook: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - url: '', - events: [], - tls: true, - authUsername: '', - authPassword: '', - secret: '', - enabled: true, - logs: '', - attempts: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('put', uri, apiHeaders, apiPayload); } /** @@ -713,30 +602,6 @@ export class Webhooks { accept: 'application/json', }; - const request = this.client.call('patch', uri, apiHeaders, apiPayload); - const defaults = { - root: 'webhook', - models: { - webhook: { - defaults: { - $id: '', - $createdAt: '', - $updatedAt: '', - name: '', - url: '', - events: [], - tls: true, - authUsername: '', - authPassword: '', - secret: '', - enabled: true, - logs: '', - attempts: 0, - }, - }, - }, - }; - - return request.then((response) => applyDefaults(response, defaults)); + return this.client.call('patch', uri, apiHeaders, apiPayload); } } diff --git a/test/services/account.test.js b/test/services/account.test.js index 7c83d4c..5308e90 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -593,96 +593,6 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method listPasskeys()', async () => { - const data = { - total: 5, - passkeys: [], - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.listPasskeys(); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createPasskey()', async () => { - const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - passkeyId: '5e5ea5c16897e', - expire: '2020-10-15T06:38:00.000+00:00', - publicKey: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.createPasskey(); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getPasskey()', 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 laptop', - accessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.getPasskey(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updatePasskey()', 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 laptop', - accessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.updatePasskey('', ''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method deletePasskey()', async () => { - const data = { message: '' }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.deletePasskey(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updatePasskeyVerification()', 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 laptop', - accessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.updatePasskeyVerification( - '', - {}, - ); - - // 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', @@ -1295,39 +1205,6 @@ describe('Account', () => { expect(response).toEqual(data); }); - test('test method createPasskeyToken()', async () => { - const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - passkeyId: '5e5ea5c16897e', - expire: '2020-10-15T06:38:00.000+00:00', - publicKey: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.createPasskeyToken(); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updatePasskeyToken()', async () => { - const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - userId: '5e5ea5c168bb8', - secret: '', - expire: '2020-10-15T06:38:00.000+00:00', - phrase: 'Golden Fox', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await account.updatePasskeyToken('', {}); - - // 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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 6e8adec..3966455 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -615,12 +615,16 @@ describe('DocumentsDB', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 37fb788..748ff58 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -31,12 +31,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -101,12 +105,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -158,12 +166,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -435,12 +447,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -492,12 +508,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -571,12 +591,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -628,12 +652,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -689,12 +717,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -800,9 +832,14 @@ describe('Mongo', () => { '\\$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)); @@ -818,9 +855,14 @@ describe('Mongo', () => { '\\$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)); @@ -863,12 +905,16 @@ describe('Mongo', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 1c559c8..30e05cf 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -31,12 +31,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -101,12 +105,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -158,12 +166,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -435,12 +447,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -492,12 +508,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -588,12 +608,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -645,12 +669,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -706,12 +734,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -859,9 +891,14 @@ describe('Mysql', () => { '\\$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)); @@ -877,9 +914,14 @@ describe('Mysql', () => { '\\$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)); @@ -922,12 +964,16 @@ describe('Mysql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/organization.test.js b/test/services/organization.test.js index b441acf..6437dd6 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -24,6 +24,13 @@ describe('Organization', () => { 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', @@ -50,6 +57,13 @@ describe('Organization', () => { 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', diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index 6109f80..f002ac0 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -31,12 +31,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -101,12 +105,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -158,12 +166,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -438,12 +450,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -495,12 +511,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -608,12 +628,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -668,12 +692,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -728,12 +756,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -785,12 +817,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -846,12 +882,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1002,9 +1042,14 @@ describe('Postgresql', () => { '\\$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)); @@ -1020,9 +1065,14 @@ describe('Postgresql', () => { '\\$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)); @@ -1065,12 +1115,16 @@ describe('Postgresql', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/project.test.js b/test/services/project.test.js index f51f0b0..de5af44 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -1164,7 +1164,6 @@ describe('Project', () => { name: 'My Web App', type: 'web', applicationId: 'com.company.appname', - fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1186,7 +1185,6 @@ describe('Project', () => { name: 'My Web App', type: 'web', applicationId: 'com.company.appname', - fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1630,43 +1628,6 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updatePasskeyPolicy()', async () => { - const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'New Project', - teamId: '1592981250', - region: 'fra', - smtpEnabled: true, - smtpSenderName: 'John Appwrite', - smtpSenderEmail: 'john@appwrite.io', - smtpReplyToName: 'Support Team', - smtpReplyToEmail: 'support@appwrite.io', - smtpHost: 'mail.appwrite.io', - smtpPort: 25, - smtpUsername: 'emailuser', - smtpPassword: 'smtp-password', - smtpSecure: 'tls', - pingCount: 1, - pingedAt: '2020-10-15T06:38:00.000+00:00', - labels: [], - status: 'active', - onboarding: {}, - authMethods: [], - services: [], - protocols: [], - blocks: [], - consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updatePasskeyPolicy(''); - - // 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', @@ -1815,43 +1776,6 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updatePasswordRotationPolicy()', async () => { - const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'New Project', - teamId: '1592981250', - region: 'fra', - smtpEnabled: true, - smtpSenderName: 'John Appwrite', - smtpSenderEmail: 'john@appwrite.io', - smtpReplyToName: 'Support Team', - smtpReplyToEmail: 'support@appwrite.io', - smtpHost: 'mail.appwrite.io', - smtpPort: 25, - smtpUsername: 'emailuser', - smtpPassword: 'smtp-password', - smtpSecure: 'tls', - pingCount: 1, - pingedAt: '2020-10-15T06:38:00.000+00:00', - labels: [], - status: 'active', - onboarding: {}, - authMethods: [], - services: [], - protocols: [], - blocks: [], - consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updatePasswordRotationPolicy(); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { '\\$id': 'password-dictionary', @@ -2057,8 +1981,7 @@ describe('Project', () => { test('test method getPolicy()', async () => { const data = { '\\$id': 'password-dictionary', - rpId: 'example.com', - origins: [], + enabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 252d406..1c1cf2f 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -196,12 +196,16 @@ describe('TablesDB', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/users.test.js b/test/services/users.test.js index 169c776..3123510 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -675,65 +675,6 @@ describe('Users', () => { expect(response).toEqual(data); }); - test('test method listPasskeys()', async () => { - const data = { - total: 5, - passkeys: [], - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.listPasskeys(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getPasskey()', 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 laptop', - accessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.getPasskey('', ''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updatePasskey()', 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 laptop', - accessedAt: '2020-10-15T06:38:00.000+00:00', - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.updatePasskey( - '', - '', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method deletePasskey()', async () => { - const data = { message: '' }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await users.deletePasskey('', ''); - - // 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', diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 0d84ead..3df11da 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -587,12 +587,16 @@ describe('VectorsDB', () => { '\\$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: '••••••••', + credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js deleted file mode 100644 index 5c693f8..0000000 --- a/test/services/waf.test.js +++ /dev/null @@ -1,354 +0,0 @@ -const { Client } = require('../../dist/client'); -const { Waf } = require('../../dist/services/waf'); - -const { fetch: mockedFetch, Response } = require('undici'); -jest.mock('undici', () => ({ - ...jest.requireActual('undici'), - fetch: jest.fn(), -})); - -describe('Waf', () => { - const client = new Client(); - const waf = new Waf(client); - - test('test method listRules()', async () => { - const data = { - total: 5, - rules: [], - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.listRules(); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createBypassRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.createBypassRule( - '', - 'api', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updateBypassRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.updateBypassRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createChallengeRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - challengeType: 'compute', - difficulty: 3, - ttl: 1800, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.createChallengeRule( - '', - 'api', - '', - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updateChallengeRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - challengeType: 'compute', - difficulty: 3, - ttl: 1800, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.updateChallengeRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createDenyRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.createDenyRule('', 'api', ''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updateDenyRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.updateDenyRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createRateLimitRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - limit: 1000, - interval: 60, - key: 'userId', - strategy: 'slidingWindow', - maxBucketSize: 200, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.createRateLimitRule( - '', - 'api', - '', - 1, - 1, - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updateRateLimitRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - limit: 1000, - interval: 60, - key: 'userId', - strategy: 'slidingWindow', - maxBucketSize: 200, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.updateRateLimitRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method createRedirectRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - location: '/maintenance', - statusCode: 301, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.createRedirectRule( - '', - 'api', - '', - '', - 1, - ); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method updateRedirectRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - location: '/maintenance', - statusCode: 301, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.updateRedirectRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method getRule()', async () => { - const data = { - '\\$id': 'wafRule1', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - name: 'Block anonymous POST traffic', - description: 'Blocks anonymous POST calls to /v1/graphql', - teamId: '5e5ea5c16897e', - projectId: 'cloudConsole', - resourceType: 'functions', - resourceId: 'functionId', - action: 'deny', - priority: 100, - enabled: true, - conditions: [], - config: {}, - location: '/maintenance', - statusCode: 301, - }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.getRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); - test('test method deleteRule()', async () => { - const data = { message: '' }; - mockedFetch.mockImplementation(() => Response.json(data)); - const response = await waf.deleteRule(''); - - // Remove custom toString method on the objects to allow for clean data comparison. - delete response.toString; - - expect(response).toEqual(data); - }); -}); From 597ac9d8b2791cf465dea419b2e36948d3e83c1f Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 16:36:38 +0100 Subject: [PATCH 3/7] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 81 +- README.md | 4 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 1 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/update-email.md | 10 +- docs/examples/messaging/update-push.md | 4 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 +- .../project/update-o-auth-2-auth-0.md | 2 +- .../project/update-o-auth-2-discord.md | 2 +- .../project/update-o-auth-2-git-hub.md | 2 +- .../project/update-o-auth-2-google.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 2 +- .../project/update-o-auth-2-microsoft.md | 2 +- docs/examples/project/update-o-auth-2-okta.md | 2 +- .../project/update-o-auth-2-salesforce.md | 2 +- docs/examples/project/update-o-auth-2-zoho.md | 2 +- .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 59 +- src/enums/databases-index-type.ts | 1 + src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 3 +- src/models.ts | 1135 ++- src/services/account.ts | 2254 ++++- src/services/activities.ts | 102 +- src/services/advisor.ts | 229 +- src/services/apps.ts | 633 +- src/services/backups.ts | 355 +- src/services/databases.ts | 3189 +++++-- src/services/documents-db.ts | 1179 ++- src/services/domains.ts | 1398 ++- src/services/embeddings.ts | 35 +- src/services/functions.ts | 1059 ++- src/services/locale.ts | 211 +- src/services/messaging.ts | 3171 ++++--- src/services/mongo.ts | 1672 +++- src/services/mysql.ts | 1926 +++- src/services/oauth-2.ts | 359 +- src/services/organization.ts | 735 +- src/services/postgresql.ts | 2071 ++++- src/services/presences.ts | 94 +- src/services/project.ts | 7877 +++++++++++++---- src/services/proxy.ts | 217 +- src/services/sites.ts | 979 +- src/services/storage.ts | 326 +- src/services/tables-db.ts | 3640 ++++++-- src/services/teams.ts | 380 +- src/services/tokens.ts | 142 +- src/services/users.ts | 1808 +++- src/services/vectors-db.ts | 1181 ++- src/services/waf.ts | 2415 +++++ src/services/webhooks.ts | 217 +- src/topic.ts | 103 - test/services/account.test.js | 329 +- test/services/activities.test.js | 2 +- test/services/advisor.test.js | 12 +- test/services/apps.test.js | 60 +- test/services/avatars.test.js | 6 +- test/services/backups.test.js | 42 +- test/services/databases.test.js | 310 +- test/services/documents-d-b.test.js | 172 +- test/services/domains.test.js | 162 +- test/services/functions.test.js | 94 +- test/services/messaging.test.js | 282 +- test/services/mongo.test.js | 138 +- test/services/mysql.test.js | 138 +- test/services/oauth2.test.js | 12 +- test/services/organization.test.js | 98 +- test/services/postgresql.test.js | 158 +- test/services/presences.test.js | 24 +- test/services/project.test.js | 569 +- test/services/proxy.test.js | 36 +- test/services/sites.test.js | 86 +- test/services/storage.test.js | 48 +- test/services/tables-d-b.test.js | 338 +- test/services/teams.test.js | 60 +- test/services/tokens.test.js | 12 +- test/services/users.test.js | 211 +- test/services/vectors-d-b.test.js | 144 +- test/services/waf.test.js | 354 + test/services/webhooks.test.js | 24 +- test/topic.test.js | 44 - 129 files changed, 37057 insertions(+), 8775 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts delete mode 100644 src/topic.ts create mode 100644 test/services/waf.test.js delete mode 100644 test/topic.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..2af02ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,63 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - ## 30.0.0 -* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed -* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed -* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` -* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model -* Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `account.createIdTokenSession` and email verification and recovery OTP methods +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models +* Breaking: removed `organization.createKey`, `listKeys`, `updateKey` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys` +* Breaking: removed `BillingPlanGroup.Starter` +* Breaking: removed `Models.DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList.pricing` +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `string[]` +* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage` +* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider +* Updated: missing response fields fall back to their documented defaults +* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned + +## 29.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers -* Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics -* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + +## 29.3.1 + +* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys +* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy + +## 29.3.0 + +* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification` +* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in +* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey` +* Added: `project.updatePasskeyPolicy` to configure passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..14ec8d8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '', // optional + name: '', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '', + name: '', +}); +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..78a1de6 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,6 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 499e392..256234c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -18,10 +18,10 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional - replyToEmail: 'email@example.com', // optional - replyToName: '', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 04e86f7..0fc7a9a 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -10,18 +10,18 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateEmail({ messageId: '', - subject: '', // optional - content: '', // optional topics: [], // optional users: [], // optional targets: [], // optional + subject: '', // optional + content: '', // optional + draft: false, // optional + html: false, // optional cc: [], // optional bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional replyToEmail: 'email@example.com', // optional replyToName: '', // optional - draft: false, // optional - html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index d62e346..5d0e6b7 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -10,11 +10,11 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updatePush({ messageId: '', - title: '', // optional - body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional data: {}, // optional action: '<ACTION>', // optional image: '<ID1:ID2>', // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 7c95f4f..940474a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,10 +10,10 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + content: '<CONTENT>', // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '<CLIENT_ID>', // optional scope: '<SCOPE>', // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '<CLIENT_SECRET>', // optional codeVerifier: '<CODE_VERIFIER>', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..c0add3b --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..5400831 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..417f5c8 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..88d3d57 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..14bb9a8 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 9319a90..e1392e0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,8 +13,8 @@ const result = await project.updateOAuth2Apple({ keyId: '<KEY_ID>', // optional teamId: '<TEAM_ID>', // optional p8File: '<P8_FILE>', // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 61fb73c..79ba89d 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional endpoint: '<ENDPOINT>', // optional - prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index d76ac95..a8d5282 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index cb497db..8d3fbdd 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 0325eef..fc081aa 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,8 +12,8 @@ const result = await project.updateOAuth2Google({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index cb310ae..af88267 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kakao({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7a7edb2..2cb3efe 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '<APPLICATION_ID>', // optional applicationSecret: '<APPLICATION_SECRET>', // optional tenant: '<TENANT>', // optional - prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 4b6deba..7f0052b 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -13,7 +13,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '<CLIENT_SECRET>', // optional domain: 'example.com', // optional authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional - prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 12698d0..ffd57c0 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '<CUSTOMER_KEY>', // optional customerSecret: '<CUSTOMER_SECRET>', // optional - prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index baa7bc8..2ccc10d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '<RP_ID>', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..2d45ad5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional + membershipId: '<MEMBERSHIP_ID>', // optional }); ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '<USER_ID>', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + location: '<LOCATION>', + statusCode: 300, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + location: '<LOCATION>', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..b36b64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..9272cdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..3012e45 100644 --- a/src/client.ts +++ b/src/client.ts @@ -44,6 +44,59 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record<string, unknown>; + properties?: Record<string, DefaultsShape>; +}; + +type Defaults = { + root: DefaultsShape; + models: Record<string, DefaultsModel>; +}; + +export function applyDefaults<T>(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record<string, DefaultsModel>, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record<string, unknown> = { ...model.defaults, ...value }; + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + // The spread drops the non-enumerable JSON toString that Client.call attaches. + if (Object.prototype.hasOwnProperty.call(value, 'toString')) { + Object.defineProperty(result, 'toString', { + value: () => JSONbig.stringify(result), + writable: true, + enumerable: false, + configurable: true, + }); + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +133,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +194,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.5.0', }; /** diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833..275668e 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4..09fd95c 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..3908265 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,13 +28,13 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; -export { Topic, ResolvedTopic } from './topic'; export { Operator, Condition } from './operator'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; @@ -119,3 +119,4 @@ export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..a2b3d6c 100644 --- a/src/models.ts +++ b/src/models.ts @@ -25,6 +25,7 @@ import { ProxyRuleStatus } from './enums/proxy-rule-status'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +504,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +516,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -744,39 +747,39 @@ export namespace Models { /** * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ - status?: DatabaseStatus; + status?: DatabaseStatus | null; /** * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ - engine?: string; + engine?: string | null; /** * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. */ - specification?: string; + specification?: string | null; /** * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ - replicas?: number; + replicas?: number | null; /** * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. */ - error?: string; + error?: string | null; /** * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. */ - containerStatus?: string; + containerStatus?: string | null; /** * 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; + lifecycleState?: string | null; /** * Database backup policies. */ - policies?: BackupPolicy[]; + policies?: BackupPolicy[] | null; /** * Database backup archives. */ - archives?: BackupArchive[]; + archives?: BackupArchive[] | null; }; /** @@ -934,7 +937,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -950,11 +953,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -984,7 +987,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -996,15 +999,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1034,7 +1037,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1046,15 +1049,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -1084,7 +1087,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1096,15 +1099,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1134,7 +1137,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1146,7 +1149,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -1176,7 +1179,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1192,7 +1195,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1222,7 +1225,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1242,7 +1245,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1272,7 +1275,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1288,7 +1291,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1318,7 +1321,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1334,7 +1337,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1364,7 +1367,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1380,7 +1383,7 @@ export namespace Models { /** * Default value for attribute when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -1410,7 +1413,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1472,7 +1475,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1484,7 +1487,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -1514,7 +1517,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1526,7 +1529,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -1556,7 +1559,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1568,7 +1571,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -1598,7 +1601,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1614,11 +1617,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1648,7 +1651,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1660,11 +1663,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1694,7 +1697,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1706,11 +1709,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1740,7 +1743,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1752,11 +1755,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1844,7 +1847,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1882,7 +1885,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -2030,7 +2033,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2046,11 +2049,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2080,7 +2083,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2092,15 +2095,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2130,7 +2133,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2142,15 +2145,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -2180,7 +2183,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2192,15 +2195,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2230,7 +2233,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2242,7 +2245,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -2272,7 +2275,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2288,7 +2291,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2318,7 +2321,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2338,7 +2341,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2368,7 +2371,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2384,7 +2387,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2414,7 +2417,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2430,7 +2433,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2460,7 +2463,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2476,7 +2479,7 @@ export namespace Models { /** * Default value for column when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -2506,7 +2509,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2568,7 +2571,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2580,7 +2583,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -2610,7 +2613,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2622,7 +2625,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -2652,7 +2655,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2664,7 +2667,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -2694,7 +2697,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2710,11 +2713,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2744,7 +2747,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2756,11 +2759,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2790,7 +2793,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2802,11 +2805,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2836,7 +2839,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2848,11 +2851,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2898,7 +2901,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -2944,7 +2947,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -3052,7 +3055,7 @@ export namespace Models { /** * Presence status. */ - status?: string; + status?: string | null; /** * Presence source. */ @@ -3060,7 +3063,7 @@ export namespace Models { /** * Presence expiry date in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * Presence metadata. */ @@ -3092,15 +3095,15 @@ export namespace Models { /** * Hashed user password. */ - password?: string; + password?: string | null; /** * Password hashing algorithm. */ - hash?: string; + hash?: string | null; /** * Password hashing algorithm configuration. */ - hashOptions?: object; + hashOptions?: object | null; /** * User registration date in ISO 8601 format. */ @@ -3132,27 +3135,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3176,11 +3179,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3346,27 +3349,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3390,11 +3393,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3654,47 +3657,47 @@ export namespace Models { /** * City */ - city?: string; + city?: string | null; /** * Name of timezone */ - timeZone?: string; + timeZone?: string | null; /** * Postal code */ - postalCode?: string; + postalCode?: string | null; /** * Latitude */ - latitude?: number; + latitude?: number | null; /** * Longitude */ - longitude?: number; + longitude?: number | null; /** * Autonomous System Number (ASN) of the IP */ - autonomousSystemNumber?: string; + autonomousSystemNumber?: string | null; /** * Organization that owns the ASN */ - autonomousSystemOrganization?: string; + autonomousSystemOrganization?: string | null; /** * Internet service provider of the IP */ - isp?: string; + isp?: string | null; /** * Connection type of the IP (e.g. cable, cellular, corporate) */ - connectionType?: string; + connectionType?: string | null; /** * User type classification of the IP (e.g. residential, business, hosting) */ - connectionUsageType?: string; + connectionUsageType?: string | null; /** * Registered organization of the IP */ - connectionOrganization?: string; + connectionOrganization?: string | null; }; /** @@ -4201,6 +4204,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number | null; /** * Function execution timeout in seconds. */ @@ -4342,7 +4349,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile?: string; + fallbackFile?: string | null; }; /** @@ -4538,7 +4545,7 @@ export namespace Models { /** * The scheduled time for execution. If left empty, execution will be queued immediately. */ - scheduledAt?: string; + scheduledAt?: string | null; }; /** @@ -4652,87 +4659,91 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled?: boolean; + wafEnabled?: boolean | null; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * First time the project received a non-console API request. Empty until the project is used. */ - firstAccessedAt?: string; + firstAccessedAt?: string | null; /** * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. */ - mcpAccessedAt?: string; + mcpAccessedAt?: string | null; /** * OAuth2 server status */ - oAuth2ServerEnabled?: boolean; + oAuth2ServerEnabled?: boolean | null; /** * OAuth2 server authorization URL */ - oAuth2ServerAuthorizationUrl?: string; + oAuth2ServerAuthorizationUrl?: string | null; /** * OAuth2 server allowed scopes */ - oAuth2ServerScopes?: string[]; + oAuth2ServerScopes?: string[] | null; /** * OAuth2 server scopes used when an authorization request omits the scope parameter */ - oAuth2ServerDefaultScopes?: string[]; + oAuth2ServerDefaultScopes?: string[] | null; /** * Scopes an application may request when installed on a team */ - oAuth2ServerInstallationScopes?: string[]; + oAuth2ServerInstallationScopes?: string[] | null; /** * OAuth2 server accepted RFC 9396 authorization_details types */ - oAuth2ServerAuthorizationDetailsTypes?: string[]; + oAuth2ServerAuthorizationDetailsTypes?: string[] | null; /** * OAuth2 server access token duration in seconds for confidential clients */ - oAuth2ServerAccessTokenDuration?: number; + oAuth2ServerAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for confidential clients */ - oAuth2ServerRefreshTokenDuration?: number; + oAuth2ServerRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicAccessTokenDuration?: number; + oAuth2ServerPublicAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicRefreshTokenDuration?: number; + oAuth2ServerPublicRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for app installation access tokens */ - oAuth2ServerInstallationAccessTokenDuration?: number; + oAuth2ServerInstallationAccessTokenDuration?: number | null; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ - oAuth2ServerConfidentialPkce?: boolean; + oAuth2ServerConfidentialPkce?: boolean | null; /** * URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured. */ - oAuth2ServerVerificationUrl?: string; + oAuth2ServerVerificationUrl?: string | null; /** * Number of characters in the device flow user code, excluding the formatting separator. */ - oAuth2ServerUserCodeLength?: number; + oAuth2ServerUserCodeLength?: number | null; /** * Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`. */ - oAuth2ServerUserCodeFormat?: string; + oAuth2ServerUserCodeFormat?: string | null; /** * Lifetime in seconds of device flow device codes and user codes. */ - oAuth2ServerDeviceCodeDuration?: number; + oAuth2ServerDeviceCodeDuration?: number | null; /** * OAuth2 server discovery URL */ - oAuth2ServerDiscoveryUrl?: string; + oAuth2ServerDiscoveryUrl?: string | null; }; /** @@ -5898,7 +5909,7 @@ export namespace Models { /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ - maxAge?: number; + maxAge?: number | null; }; /** @@ -6251,6 +6262,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6410,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6572,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6822,7 +6873,7 @@ export namespace Models { /** * Type of deployment resource: function, site, or dedicatedDatabase. */ - deploymentResourceType?: ProxyRuleDeploymentResourceType; + deploymentResourceType?: ProxyRuleDeploymentResourceType | null; /** * ID of deployment's resource (site or function ID). Used if type is "deployment" */ @@ -6931,6 +6982,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -7058,15 +7205,15 @@ export namespace Models { /** * The scheduled time for message. */ - scheduledAt?: string; + scheduledAt?: string | null; /** * The time when the message was delivered. */ - deliveredAt?: string; + deliveredAt?: string | null; /** * Delivery errors if any. */ - deliveryErrors?: string[]; + deliveryErrors?: string[] | null; /** * Number of recipients the message was delivered to. */ @@ -7120,11 +7267,11 @@ export namespace Models { /** * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. */ - qos?: number; + qos?: number | null; /** - * Message retention in seconds for offline delivery. + * Message retention in seconds for offline delivery. Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. */ - expiry?: number; + expiry?: number | null; }; /** @@ -7226,7 +7373,7 @@ export namespace Models { /** * Provider ID. */ - providerId?: string; + providerId?: string | null; /** * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ @@ -7304,15 +7451,15 @@ export namespace Models { /** * Time the insight was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; /** * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - dismissedAt?: string; + dismissedAt?: string | null; /** * User ID that dismissed the insight. Empty when not dismissed. */ - dismissedBy?: string; + dismissedBy?: string | null; }; /** @@ -7388,7 +7535,7 @@ export namespace Models { /** * Time the report was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; }; /** @@ -7566,7 +7713,7 @@ export namespace Models { /** * Archive size in bytes. Null until the size is known. */ - size?: number; + size?: number | null; /** * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ @@ -7574,7 +7721,7 @@ export namespace Models { /** * The backup start time. Null until the backup starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -7590,11 +7737,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this archive should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this archive should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; }; /** @@ -7648,23 +7795,23 @@ export namespace Models { /** * Backup start time in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Backup completion time in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Backup verification time in ISO 8601 format. */ - verifiedAt?: string; + verifiedAt?: string | null; /** * Backup expiration time in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * 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; + logPosition?: string | null; /** * Error message if backup failed. */ @@ -7718,35 +7865,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth?: number; + bandwidth?: number | null; /** * Storage limit */ - storage?: number; + storage?: number | null; /** * Users limit */ - users?: number; + users?: number | null; /** * Executions limit */ - executions?: number; + executions?: number | null; /** * GBHours limit */ - GBHours?: number; + GBHours?: number | null; /** * Image transformations limit */ - imageTransformations?: number; + imageTransformations?: number | null; /** * Auth phone limit */ - authPhone?: number; + authPhone?: number | null; /** * Budget limit percentage */ - budgetLimit?: number; + budgetLimit?: number | null; }; /** @@ -7796,7 +7943,7 @@ export namespace Models { /** * Members */ - members?: number; + members?: number | null; /** * Webhooks */ @@ -7805,6 +7952,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments: number; /** * Projects */ @@ -7892,7 +8043,7 @@ export namespace Models { /** * Activity log days */ - activityLogs?: number; + activityLogs?: number | null; /** * Usage history days */ @@ -7900,11 +8051,11 @@ export namespace Models { /** * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ - usageLogsIntervals?: string[]; + usageLogsIntervals?: string[] | null; /** * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. */ - usageAggregateOnlyMetrics?: string[]; + usageAggregateOnlyMetrics?: string[] | null; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -7916,7 +8067,7 @@ export namespace Models { /** * Additional resources. Null when the plan does not support usage billing. */ - usage?: UsageBillingPlan; + usage?: UsageBillingPlan | null; /** * Addons */ @@ -7944,7 +8095,7 @@ export namespace Models { /** * ISO country codes eligible for this regional plan. Empty means no restriction. */ - eligibleCountries?: string[]; + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8000,7 +8151,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled?: boolean; + backupsEnabled?: boolean | null; /** * Whether usage addons are calculated per project. */ @@ -8012,7 +8163,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies?: number; + backupPolicies?: number | null; /** * Maximum function and site deployment size in MB */ @@ -8021,6 +8172,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8028,7 +8183,7 @@ export namespace Models { /** * Plan specific limits */ - limits?: BillingPlanLimits; + limits?: BillingPlanLimits | null; /** * Group of this billing plan for variants */ @@ -8036,7 +8191,7 @@ export namespace Models { /** * Details of the program this plan is a part of. */ - program?: Program; + program?: Program | null; /** * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. */ @@ -8044,7 +8199,7 @@ export namespace Models { /** * Dedicated database limits available to this plan. */ - dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; + dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits | null; }; /** @@ -8054,11 +8209,11 @@ export namespace Models { /** * Addon seats */ - seats?: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails | null; /** * Addon projects */ - projects?: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails | null; }; /** @@ -8084,7 +8239,7 @@ export namespace Models { /** * Price currency */ - currency?: string; + currency?: string | null; /** * Price */ @@ -8106,11 +8261,11 @@ export namespace Models { /** * Credits limit per billing cycle */ - credits?: number; + credits?: number | null; /** * Daily credits limit (if applicable) */ - dailyCredits?: number; + dailyCredits?: number | null; }; /** @@ -8120,79 +8275,79 @@ export namespace Models { /** * Minimum CPU allocation in millicores. */ - minCpu?: number; + minCpu?: number | null; /** * Maximum CPU allocation in millicores. */ - maxCpu?: number; + maxCpu?: number | null; /** * Minimum memory allocation in megabytes. */ - minMemoryMb?: number; + minMemoryMb?: number | null; /** * Maximum memory allocation in megabytes. */ - maxMemoryMb?: number; + maxMemoryMb?: number | null; /** * Minimum storage allocation in gigabytes. */ - minStorageGb?: number; + minStorageGb?: number | null; /** * Maximum storage allocation in gigabytes. */ - maxStorageGb?: number; + maxStorageGb?: number | null; /** * Maximum number of high-availability replicas per dedicated database. */ - maxReplicas?: number; + maxReplicas?: number | null; /** * Maximum number of client connections. */ - maxConnections?: number; + maxConnections?: number | null; /** * Maximum number of entries allowed in the IP allowlist. */ - maxIpAllowlistSize?: number; + maxIpAllowlistSize?: number | null; /** * Maximum number of database extensions that can be enabled. */ - maxExtensions?: number; + maxExtensions?: number | null; /** * Maximum number of days a backup can be retained. */ - maxBackupRetentionDays?: number; + maxBackupRetentionDays?: number | null; /** * Maximum number of days of point-in-time recovery data that can be retained. */ - maxPitrRetentionDays?: number; + maxPitrRetentionDays?: number | null; /** * Maximum number of rows a single SQL API query can return. */ - maxSqlApiMaxRows?: number; + maxSqlApiMaxRows?: number | null; /** * Maximum response size in bytes for a single SQL API query. */ - maxSqlApiMaxBytes?: number; + maxSqlApiMaxBytes?: number | null; /** * Maximum execution time in seconds for a single SQL API query. */ - maxSqlApiTimeoutSeconds?: number; + maxSqlApiTimeoutSeconds?: number | null; /** * Maximum number of SQL statement types that can be permitted through the SQL API. */ - maxSqlApiAllowedStatements?: number; + maxSqlApiAllowedStatements?: number | null; /** * SQL statement types permitted through the SQL API. */ - allowedSqlStatements?: string[]; + allowedSqlStatements?: string[] | null; /** * Storage classes available for dedicated databases. */ - allowedStorageClasses?: string[]; + allowedStorageClasses?: string[] | null; /** * Replica synchronization modes available for dedicated databases. */ - allowedSyncModes?: string[]; + allowedSyncModes?: string[] | null; }; /** @@ -8236,7 +8391,7 @@ export namespace Models { /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - expiredAt?: string; + expiredAt?: string | null; }; /** @@ -8266,7 +8421,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number | null; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8563,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string | null; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string | null; /** * Database engine version. */ @@ -8432,7 +8587,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number | null; /** * Database username for connections. */ @@ -8444,7 +8599,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number | null; /** * Full database connection string (URI format). */ @@ -8464,11 +8619,11 @@ export namespace Models { /** * Last activity timestamp in ISO 8601 format. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; /** * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. */ - idleUntil?: string; + idleUntil?: string | null; /** * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. */ @@ -8500,7 +8655,7 @@ export namespace Models { /** * Time the in-flight storage resize started, in ISO 8601 format. */ - storageResizeStartedAt?: string; + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8658,7 +8813,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string | null; /** * Project ID. */ @@ -8666,7 +8821,7 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string | null; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ @@ -8678,15 +8833,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string | null; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string | null; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string | null; /** * Error message if restoration failed. */ @@ -8720,7 +8875,7 @@ export namespace Models { /** * Connection statistics. Null when the database has not been probed. */ - connections?: DatabaseStatusConnections; + connections?: DatabaseStatusConnections | null; /** * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. */ @@ -8728,7 +8883,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -8744,7 +8899,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -8856,7 +9011,7 @@ export namespace Models { /** * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus?: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum | null; /** * Team ID. */ @@ -8886,7 +9041,7 @@ export namespace Models { /** * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price?: number; + price?: number | null; /** * Price period in years. */ @@ -8898,7 +9053,7 @@ export namespace Models { /** * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. */ - renewalPrice?: number; + renewalPrice?: number | null; /** * Renewal price period in years. */ @@ -8960,11 +9115,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -8998,15 +9153,15 @@ export namespace Models { /** * Time the operation was requested, in ISO 8601 format. */ - requestedAt?: string; + requestedAt?: string | null; /** * Time the operation started, in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Time the operation reached a terminal state, in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ @@ -9046,7 +9201,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -9062,7 +9217,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * Per-pod statuses for the primary and every replica. */ @@ -9124,7 +9279,7 @@ export namespace Models { /** * Project budget limit. Null when no budget is set. */ - billingBudget?: number; + billingBudget?: number | null; /** * Project budget limit */ @@ -9148,43 +9303,43 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string | null; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string | null; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string | null; /** * Start date of trial. */ - billingTrialStartDate?: string; + billingTrialStartDate?: string | null; /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number | null; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string | null; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string | null; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string | null; /** * Default payment method. */ - billingAddressId?: string; + billingAddressId?: string | null; /** * Backup payment method. */ - backupPaymentMethodId?: string; + backupPaymentMethodId?: string | null; /** * Team status. */ @@ -9192,39 +9347,39 @@ export namespace Models { /** * Remarks on team status. */ - remarks?: string; + remarks?: string | null; /** * Organization agreements */ - agreementBAA?: string; + agreementBAA?: string | null; /** * Program manager's name. */ - programManagerName?: string; + programManagerName?: string | null; /** * Program manager's calendar link. */ - programManagerCalendar?: string; + programManagerCalendar?: string | null; /** * Program's discord channel name. */ - programDiscordChannelName?: string; + programDiscordChannelName?: string | null; /** * Program's discord channel URL. */ - programDiscordChannelUrl?: string; + programDiscordChannelUrl?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * Billing plan selected for downgrade. */ - billingPlanDowngrade?: string; + billingPlanDowngrade?: string | null; /** * Tax Id */ - billingTaxId?: string; + billingTaxId?: string | null; /** * Marked for deletion */ @@ -9284,11 +9439,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this policy should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this policy should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; /** * How many days to keep the backup before it will be automatically deleted. */ @@ -9448,7 +9603,7 @@ export namespace Models { /** * The restoration start time. Null until the restoration starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -9586,11 +9741,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -9622,47 +9777,47 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource | null; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource | null; /** * Member additional resources */ - member?: AdditionalResource; + member?: AdditionalResource | null; /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource | null; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource | null; /** * Realtime bandwidth additional resources */ - realtimeBandwidth?: AdditionalResource; + realtimeBandwidth?: AdditionalResource | null; /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource | null; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource | null; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource | null; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource | null; /** * Credits additional resources */ - credits?: AdditionalResource; + credits?: AdditionalResource | null; }; /** @@ -9814,7 +9969,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9856,7 +10011,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9928,7 +10083,7 @@ export namespace Models { /** * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9970,7 +10125,7 @@ export namespace Models { /** * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -10132,11 +10287,11 @@ export namespace Models { /** * Granted RFC 9396 authorization details as a JSON string. */ - authorization_details?: string; + authorization_details?: string | null; /** * OpenID Connect ID token. Returned when the `openid` scope is granted. */ - id_token?: string; + id_token?: string | null; }; /** @@ -10150,47 +10305,47 @@ export namespace Models { /** * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. */ - token_use?: string; + token_use?: string | null; /** * OAuth2 token type. */ - token_type?: string; + token_type?: string | null; /** * Space-separated scopes granted to the token. */ - scope?: string; + scope?: string | null; /** * OAuth2 client ID the token was issued to. */ - client_id?: string; + client_id?: string | null; /** * ID of the user who authorized the token. */ - sub?: string; + sub?: string | null; /** * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). */ - aud?: string[]; + aud?: string[] | null; /** * Issuer URL of the token. */ - iss?: string; + iss?: string | null; /** * Expiration time as a Unix timestamp in seconds. */ - exp?: number; + exp?: number | null; /** * Issued-at time as a Unix timestamp in seconds. */ - iat?: number; + iat?: number | null; /** * Unique identifier of the token. */ - jti?: string; + jti?: string | null; /** * Granted RFC 9396 authorization details, restricted to what the user can currently access. */ - authorization_details?: Record<string, any>[]; + authorization_details?: Record<string, any>[] | null; }; /** @@ -10289,6 +10444,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..a321bd6 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +186,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +297,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + consents: [], + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +542,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +648,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +824,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +935,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1084,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1185,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1348,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1470,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1684,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1850,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1966,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2026,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2061,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2097,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2128,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2161,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2193,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2226,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2258,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2330,538 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.PasskeyList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise<Models.PasskeyChallenge>; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise<Models.PasskeyChallenge>; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise<Models.PasskeyChallenge> { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { passkeyId: string }): Promise<Models.Passkey>; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise<Models.Passkey> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise<Models.Passkey>; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise<Models.Passkey>; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2940,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3062,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3189,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3300,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3411,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3502,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3611,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3679,58 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3802,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2389,14 +3852,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. - * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ createEmailPasswordSession(params: { email: string; password: string; - duration?: number; + duration?: number | null; }): Promise<Models.Session>; /** * 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. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. @@ -2405,7 +3868,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. - * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2413,14 +3876,19 @@ export class Account { createEmailPasswordSession( email: string, password: string, - duration?: number, + duration?: number | null, ): Promise<Models.Session>; createEmailPasswordSession( paramsOrFirst: - { email: string; password: string; duration?: number } | string, - ...rest: [string?, number?] + | { email: string; password: string; duration?: number | null } + | string, + ...rest: [string?, (number | null)?] ): Promise<Models.Session> { - let params: { email: string; password: string; duration?: number }; + let params: { + email: string; + password: string; + duration?: number | null; + }; if ( paramsOrFirst && @@ -2430,13 +3898,13 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; - duration?: number; + duration?: number | null; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, - duration: rest[1] as number, + duration: rest[1] as number | null, }; } @@ -2470,7 +3938,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4140,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4255,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4367,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4478,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4573,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4669,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4785,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4919,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5043,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5076,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} */ @@ -3259,6 +5085,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise<string>; /** * 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. @@ -3273,6 +5100,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5110,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise<string>; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5119,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise<string> { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5139,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5155,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5163,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5183,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5196,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskeyToken(): Promise<Models.PasskeyChallenge> { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise<Models.TokenSecret>; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise<Models.TokenSecret>; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.TokenSecret> { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5396,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5473,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5551,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5642,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5731,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5808,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5901,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5938,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6029,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..d082ca4 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,58 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + events: [], + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +171,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..303b910 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,76 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + reports: [], + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +206,65 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +405,56 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +526,44 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..ff362ed 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,72 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + apps: [], + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +450,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +523,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +569,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +647,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1019,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1206,38 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1311,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1478,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1575,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1659,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1738,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1889,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2024,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2108,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2195,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2345,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..8efb7f2 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,41 +64,71 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + archives: [], + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} params.services - Array of services to backup - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} */ createArchive(params: { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }): Promise<Models.BackupArchive>; /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} services - Array of services to backup - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} * @deprecated Use the object parameter style method for a better developer experience. */ createArchive( services: BackupServices[], - resourceId?: string, + resourceId?: string | null, ): Promise<Models.BackupArchive>; createArchive( paramsOrFirst: - | { services: BackupServices[]; resourceId?: string } + | { services: BackupServices[]; resourceId?: string | null } | BackupServices[], - ...rest: [string?] + ...rest: [(string | null)?] ): Promise<Models.BackupArchive> { - let params: { services: BackupServices[]; resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string | null }; if ( paramsOrFirst && @@ -103,12 +138,12 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string, + resourceId: rest[0] as string | null, }; } @@ -135,7 +170,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +244,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +370,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +413,7 @@ export class Backups { * @param {number} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Schedule CRON syntax. * @param {string} params.name - Policy name. Max length: 128 chars. - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -319,7 +424,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }): Promise<Models.BackupPolicy>; /** @@ -330,7 +435,7 @@ export class Backups { * @param {number} retention - Days to keep backups before deletion * @param {string} schedule - Schedule CRON syntax. * @param {string} name - Policy name. Max length: 128 chars. - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -342,7 +447,7 @@ export class Backups { retention: number, schedule: string, name?: string, - resourceId?: string, + resourceId?: string | null, enabled?: boolean, ): Promise<Models.BackupPolicy>; createPolicy( @@ -353,7 +458,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; } | string, @@ -362,7 +467,7 @@ export class Backups { number?, string?, string?, - string?, + (string | null)?, boolean?, ] ): Promise<Models.BackupPolicy> { @@ -372,7 +477,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; @@ -387,7 +492,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; } else { @@ -397,7 +502,7 @@ export class Backups { retention: rest[1] as number, schedule: rest[2] as string, name: rest[3] as string, - resourceId: rest[4] as string, + resourceId: rest[4] as string | null, enabled: rest[5] as boolean, }; } @@ -460,7 +565,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,64 +641,90 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update an existing policy using it's ID. * * @param {string} params.policyId - Policy ID. Choose a custom ID`. 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 {number} params.retention - Days to keep backups before deletion + * @param {string | null} params.name - Policy name. Max length: 128 chars. + * @param {number | null} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Cron expression - * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updatePolicy(params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * Update an existing policy using it's ID. * * @param {string} policyId - Policy ID. Choose a custom ID`. 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 {number} retention - Days to keep backups before deletion + * @param {string | null} name - Policy name. Max length: 128 chars. + * @param {number | null} retention - Days to keep backups before deletion * @param {string} schedule - Cron expression - * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePolicy( policyId: string, - name?: string, - retention?: number, + name?: string | null, + retention?: number | null, schedule?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updatePolicy( paramsOrFirst: | { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, number?, string?, boolean?] + ...rest: [ + (string | null)?, + (number | null)?, + string?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -582,18 +734,18 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { policyId: paramsOrFirst as string, - name: rest[0] as string, - retention: rest[1] as number, + name: rest[0] as string | null, + retention: rest[1] as number | null, schedule: rest[2] as string, - enabled: rest[3] as boolean, + enabled: rest[3] as boolean | null, }; } @@ -632,7 +784,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +987,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1061,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1150,27 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..0b2d328 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,69 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +246,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +366,35 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +447,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +522,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +629,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +779,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +852,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +988,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1199,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -892,11 +1259,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. @@ -905,7 +1272,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -917,11 +1284,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,7 +1297,7 @@ export class Databases { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -942,7 +1309,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -952,7 +1319,7 @@ export class Databases { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -963,7 +1330,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -979,7 +1346,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -990,7 +1357,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1053,7 +1420,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1537,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1139,7 +1586,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1151,7 +1598,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1162,7 +1609,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1174,7 +1621,7 @@ export class Databases { databaseId: string, collectionId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1185,19 +1632,26 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Collection> { let params: { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1212,7 +1666,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1222,7 +1676,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -1276,7 +1730,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1955,20 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + attributes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1472,9 +1979,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1485,9 +1992,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeBigint>; /** @@ -1498,9 +2005,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1511,9 +2018,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeBigint>; createBigIntAttribute( @@ -1523,9 +2030,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -1533,9 +2040,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeBigint> { @@ -1544,9 +2051,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -1560,9 +2067,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -1571,9 +2078,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -1638,7 +2145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,10 +2173,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. @@ -1662,10 +2186,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeBigint>; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. @@ -1675,10 +2199,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1688,10 +2212,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeBigint>; updateBigIntAttribute( paramsOrFirst: @@ -1700,20 +2224,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeBigint> { let params: { @@ -1721,10 +2245,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -1737,10 +2261,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -1748,10 +2272,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -1818,7 +2342,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1829,7 +2370,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1840,7 +2381,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.AttributeBoolean>; /** @@ -1851,7 +2392,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1862,7 +2403,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.AttributeBoolean>; createBooleanAttribute( @@ -1872,18 +2413,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -1897,7 +2438,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -1906,7 +2447,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -1963,7 +2504,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1973,8 +2531,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. @@ -1984,8 +2542,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.AttributeBoolean>; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -1994,8 +2552,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2005,8 +2563,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.AttributeBoolean>; updateBooleanAttribute( paramsOrFirst: @@ -2015,19 +2573,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2040,8 +2604,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2049,8 +2613,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2109,7 +2673,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2119,7 +2700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2130,7 +2711,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeDatetime>; /** @@ -2140,7 +2721,7 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2151,7 +2732,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeDatetime>; createDatetimeAttribute( @@ -2161,18 +2742,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2186,7 +2767,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2195,7 +2776,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2252,7 +2833,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2262,8 +2860,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. @@ -2273,8 +2871,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeDatetime>; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -2283,8 +2881,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2294,8 +2892,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeDatetime>; updateDatetimeAttribute( paramsOrFirst: @@ -2304,19 +2902,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2329,8 +2933,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2338,8 +2942,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2398,7 +3002,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2409,7 +3030,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2420,7 +3041,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEmail>; /** @@ -2431,7 +3052,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2442,7 +3063,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEmail>; createEmailAttribute( @@ -2452,18 +3073,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2477,7 +3098,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2486,7 +3107,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2543,7 +3164,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2554,8 +3193,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. @@ -2565,8 +3204,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEmail>; /** * Update an email attribute. Changing the `default` value will not update already existing documents. @@ -2576,8 +3215,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2587,8 +3226,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEmail>; updateEmailAttribute( paramsOrFirst: @@ -2597,19 +3236,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2622,8 +3267,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2631,8 +3276,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2691,7 +3336,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2703,7 +3366,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2715,7 +3378,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEnum>; /** @@ -2727,7 +3390,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2739,7 +3402,7 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEnum>; createEnumAttribute( @@ -2750,11 +3413,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2762,7 +3432,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2777,7 +3447,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2787,7 +3457,7 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -2853,7 +3523,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2865,8 +3554,8 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. @@ -2877,8 +3566,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEnum>; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -2889,8 +3578,8 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2901,8 +3590,8 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEnum>; updateEnumAttribute( paramsOrFirst: @@ -2912,11 +3601,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2924,8 +3620,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2939,8 +3635,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2949,8 +3645,8 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3018,7 +3714,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3029,9 +3744,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3042,9 +3757,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.AttributeFloat>; /** @@ -3055,9 +3770,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3068,9 +3783,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.AttributeFloat>; createFloatAttribute( @@ -3080,9 +3795,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3090,9 +3805,9 @@ export class Databases { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.AttributeFloat> { @@ -3101,9 +3816,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3117,9 +3832,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3128,9 +3843,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3195,7 +3910,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3206,10 +3938,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {string} params.newKey - New Attribute Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. @@ -3219,10 +3951,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.AttributeFloat>; /** * Update a float attribute. Changing the `default` value will not update already existing documents. @@ -3232,10 +3964,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {string} newKey - New Attribute Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3245,10 +3977,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.AttributeFloat>; updateFloatAttribute( paramsOrFirst: @@ -3257,20 +3989,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.AttributeFloat> { let params: { @@ -3278,10 +4010,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3294,10 +4026,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3305,10 +4037,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -3375,7 +4107,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3386,9 +4135,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3399,9 +4148,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeInteger>; /** @@ -3412,9 +4161,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3425,9 +4174,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeInteger>; createIntegerAttribute( @@ -3437,9 +4186,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -3447,9 +4196,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeInteger> { @@ -3458,9 +4207,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -3474,9 +4223,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -3485,9 +4234,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -3552,7 +4301,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,10 +4329,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. @@ -3576,10 +4342,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeInteger>; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -3589,10 +4355,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3602,10 +4368,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeInteger>; updateIntegerAttribute( paramsOrFirst: @@ -3614,20 +4380,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeInteger> { let params: { @@ -3635,10 +4401,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -3651,10 +4417,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -3662,10 +4428,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -3732,7 +4498,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3743,7 +4526,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3754,7 +4537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeIp>; /** @@ -3765,7 +4548,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3776,7 +4559,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeIp>; createIpAttribute( @@ -3786,18 +4569,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3811,7 +4594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3820,7 +4603,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3877,7 +4660,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3888,8 +4689,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. @@ -3899,8 +4700,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeIp>; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -3910,8 +4711,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3921,8 +4722,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeIp>; updateIpAttribute( paramsOrFirst: @@ -3931,19 +4732,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3956,8 +4763,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3965,8 +4772,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4025,7 +4832,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4035,7 +4860,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. @@ -4045,7 +4870,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributeLine>; /** * Create a geometric line attribute. @@ -4054,7 +4879,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4064,7 +4889,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributeLine>; createLineAttribute( paramsOrFirst: @@ -4073,17 +4898,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4096,7 +4921,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4104,7 +4929,7 @@ export class Databases { 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[][] | null, }; } @@ -4156,7 +4981,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4166,8 +5008,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. @@ -4177,8 +5019,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributeLine>; /** * Update a line attribute. Changing the `default` value will not update already existing documents. @@ -4187,8 +5029,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4198,8 +5040,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributeLine>; updateLineAttribute( paramsOrFirst: @@ -4208,19 +5050,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4233,8 +5081,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4242,8 +5090,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4297,7 +5145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4308,7 +5173,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4320,7 +5185,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeLongtext>; @@ -4332,7 +5197,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4344,7 +5209,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeLongtext>; @@ -4355,19 +5220,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4382,7 +5254,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4392,7 +5264,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4454,7 +5326,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4465,8 +5354,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. @@ -4476,8 +5365,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeLongtext>; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -4487,8 +5376,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4498,8 +5387,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeLongtext>; updateLongtextAttribute( paramsOrFirst: @@ -4508,19 +5397,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4533,8 +5428,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4542,8 +5437,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4602,7 +5497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4613,7 +5525,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4625,7 +5537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeMediumtext>; @@ -4637,7 +5549,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4649,7 +5561,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeMediumtext>; @@ -4660,19 +5572,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4687,7 +5606,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4697,7 +5616,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4759,7 +5678,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4770,8 +5706,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. @@ -4781,8 +5717,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeMediumtext>; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -4792,8 +5728,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4803,8 +5739,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeMediumtext>; updateMediumtextAttribute( paramsOrFirst: @@ -4813,19 +5749,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4838,8 +5780,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4847,8 +5789,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4907,7 +5849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4917,7 +5876,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. @@ -4927,7 +5886,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.AttributePoint>; /** * Create a geometric point attribute. @@ -4936,7 +5895,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4946,7 +5905,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.AttributePoint>; createPointAttribute( paramsOrFirst: @@ -4955,17 +5914,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -4978,7 +5937,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -4986,7 +5945,7 @@ export class Databases { 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[] | null, }; } @@ -5038,7 +5997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5048,8 +6024,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. @@ -5059,8 +6035,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.AttributePoint>; /** * Update a point attribute. Changing the `default` value will not update already existing documents. @@ -5069,8 +6045,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5080,8 +6056,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.AttributePoint>; updatePointAttribute( paramsOrFirst: @@ -5090,19 +6066,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5115,8 +6097,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5124,8 +6106,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5179,7 +6161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5189,7 +6188,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. @@ -5199,7 +6198,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributePolygon>; /** * Create a geometric polygon attribute. @@ -5208,7 +6207,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5218,7 +6217,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributePolygon>; createPolygonAttribute( paramsOrFirst: @@ -5227,17 +6226,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5250,7 +6249,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5258,7 +6257,7 @@ export class Databases { 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[][] | null, }; } @@ -5310,7 +6309,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5320,8 +6336,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. @@ -5331,8 +6347,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributePolygon>; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -5341,8 +6357,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5352,8 +6368,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributePolygon>; updatePolygonAttribute( paramsOrFirst: @@ -5362,19 +6378,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -5387,8 +6409,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -5396,8 +6418,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -5451,7 +6473,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5463,8 +6502,8 @@ export class Databases { * @param {string} params.relatedCollectionId - Related Collection ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Attribute Key. - * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {string | null} params.key - Attribute Key. + * @param {string | null} params.twoWayKey - Two Way Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5476,8 +6515,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.AttributeRelationship>; /** @@ -5489,8 +6528,8 @@ export class Databases { * @param {string} relatedCollectionId - Related Collection ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Attribute Key. - * @param {string} twoWayKey - Two Way Attribute Key. + * @param {string | null} key - Attribute Key. + * @param {string | null} twoWayKey - Two Way Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5502,8 +6541,8 @@ export class Databases { relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.AttributeRelationship>; createRelationshipAttribute( @@ -5514,8 +6553,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -5524,8 +6563,8 @@ export class Databases { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.AttributeRelationship> { @@ -5535,8 +6574,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -5551,8 +6590,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -5562,8 +6601,8 @@ export class Databases { relatedCollectionId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -5628,7 +6667,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5639,7 +6700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. @@ -5649,7 +6710,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }): Promise<Models.AttributeRelationship>; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -5659,7 +6720,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Attribute Key. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5669,7 +6730,7 @@ export class Databases { collectionId: string, key: string, onDelete?: RelationMutate, - newKey?: string, + newKey?: string | null, ): Promise<Models.AttributeRelationship>; updateRelationshipAttribute( paramsOrFirst: @@ -5678,17 +6739,17 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, RelationMutate?, (string | null)?] ): Promise<Models.AttributeRelationship> { let params: { databaseId: string; collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; if ( @@ -5701,7 +6762,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; } else { params = { @@ -5709,7 +6770,7 @@ export class Databases { 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 | null, }; } @@ -5754,7 +6815,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5766,7 +6849,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for text attributes, in number of characters. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5779,7 +6862,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeString>; @@ -5792,7 +6875,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for text attributes, in number of characters. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5805,7 +6888,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeString>; @@ -5817,7 +6900,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -5827,7 +6910,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -5838,7 +6921,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5854,7 +6937,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5865,7 +6948,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -5934,7 +7017,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5945,9 +7046,9 @@ export class Databases { * @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). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the string attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the string attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. @@ -5957,9 +7058,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeString>; /** * Update a string attribute. Changing the `default` value will not update already existing documents. @@ -5969,9 +7070,9 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the string attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the string attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5981,9 +7082,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeString>; updateStringAttribute( paramsOrFirst: @@ -5992,21 +7093,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeString> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6019,9 +7127,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6029,9 +7137,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6094,7 +7202,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6105,7 +7231,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6117,7 +7243,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeText>; @@ -6129,7 +7255,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6141,7 +7267,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeText>; @@ -6152,19 +7278,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6179,7 +7312,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6189,7 +7322,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6251,7 +7384,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6262,8 +7412,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6273,8 +7423,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeText>; /** * Update a text attribute. Changing the `default` value will not update already existing documents. @@ -6284,8 +7434,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6295,8 +7445,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeText>; updateTextAttribute( paramsOrFirst: @@ -6305,19 +7455,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6330,8 +7486,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6339,8 +7495,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6399,7 +7555,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7583,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6421,7 +7594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeUrl>; /** @@ -6432,7 +7605,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6443,7 +7616,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeUrl>; createUrlAttribute( @@ -6453,18 +7626,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -6478,7 +7651,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -6487,7 +7660,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -6544,7 +7717,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6555,8 +7746,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. @@ -6566,8 +7757,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeUrl>; /** * Update an url attribute. Changing the `default` value will not update already existing documents. @@ -6577,8 +7768,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6588,8 +7779,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeUrl>; updateUrlAttribute( paramsOrFirst: @@ -6598,19 +7789,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6623,8 +7820,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6632,8 +7829,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6692,7 +7889,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6704,7 +7919,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6717,7 +7932,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeVarchar>; @@ -6730,7 +7945,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6743,7 +7958,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeVarchar>; @@ -6755,7 +7970,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6765,7 +7980,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6776,7 +7991,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6792,7 +8007,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6803,7 +8018,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6872,7 +8087,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6883,9 +8116,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the varchar attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the varchar attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. @@ -6895,9 +8128,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeVarchar>; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -6907,9 +8140,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the varchar attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the varchar attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6919,9 +8152,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeVarchar>; updateVarcharAttribute( paramsOrFirst: @@ -6930,21 +8163,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeVarchar> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6957,9 +8197,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6967,9 +8207,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7032,7 +8272,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8664,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7416,8 +8703,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. @@ -7431,8 +8718,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -7441,8 +8728,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7454,8 +8741,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7467,8 +8754,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -7478,8 +8765,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -7490,8 +8777,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -7507,8 +8794,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -7519,8 +8806,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -7576,7 +8863,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7585,7 +8890,7 @@ export class Databases { * @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. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. @@ -7596,7 +8901,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7604,7 +8909,7 @@ export class Databases { * @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. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7613,7 +8918,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; createDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7621,16 +8926,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7642,14 +8947,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7694,7 +8999,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7704,7 +9038,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. @@ -7715,7 +9049,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7724,7 +9058,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7733,7 +9067,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7741,16 +9075,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7762,14 +9096,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7814,7 +9148,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7824,7 +9187,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. @@ -7836,7 +9199,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7845,7 +9208,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7855,7 +9218,7 @@ export class Databases { collectionId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; updateDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7864,17 +9227,17 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7887,7 +9250,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -7895,7 +9258,7 @@ export class Databases { 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 | null, }; } @@ -7939,7 +9302,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9444,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9603,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8192,8 +9631,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. @@ -8208,8 +9647,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -8218,8 +9657,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8232,8 +9671,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; upsertDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8245,8 +9684,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8256,8 +9695,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8268,8 +9707,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8285,8 +9724,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8297,8 +9736,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8352,7 +9791,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8362,8 +9819,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. @@ -8378,8 +9835,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -8388,8 +9845,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8402,8 +9859,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; updateDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8415,8 +9872,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8426,8 +9883,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8438,8 +9895,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8455,8 +9912,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8467,8 +9924,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8522,7 +9979,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8650,8 +10125,8 @@ export class Databases { * @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.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. + * @param {number | null} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. @@ -8664,8 +10139,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Decrement a specific attribute of a document by a given value. @@ -8675,8 +10150,8 @@ export class Databases { * @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} 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. + * @param {number | null} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8689,8 +10164,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Document>; decrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8702,11 +10177,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8714,8 +10196,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -8729,8 +10211,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8739,8 +10221,8 @@ export class Databases { 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, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8798,7 +10280,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8809,8 +10309,8 @@ export class Databases { * @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. + * @param {number | null} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. @@ -8823,8 +10323,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Increment a specific attribute of a document by a given value. @@ -8834,8 +10334,8 @@ export class Databases { * @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. + * @param {number | null} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8848,8 +10348,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Document>; incrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8861,11 +10361,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8873,8 +10380,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -8888,8 +10395,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8898,8 +10405,8 @@ export class Databases { 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, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8957,7 +10464,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,12 +10592,42 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9096,7 +10651,7 @@ export class Databases { }): Promise<Models.Index>; /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9234,7 +10789,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10898,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..8d1f7f6 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,69 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class DocumentsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class DocumentsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class DocumentsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1384,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -988,7 +1396,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1000,7 +1408,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -1013,7 +1421,7 @@ export class DocumentsDB { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -1025,7 +1433,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1035,7 +1443,7 @@ export class DocumentsDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1046,7 +1454,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1062,7 +1470,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1073,7 +1481,7 @@ export class DocumentsDB { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1136,7 +1544,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1660,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1848,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2097,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2295,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2430,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2578,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2731,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2872,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +3030,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3217,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3404,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3696,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3872,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3999,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4195,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4303,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3570,33 +4419,33 @@ export class DocumentsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3605,12 +4454,12 @@ export class DocumentsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3637,7 +4486,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4646,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4733,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4817,51 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..12834f0 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,62 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + domains: [], + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +199,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +334,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +443,35 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + prices: [], + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +524,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +699,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +803,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +904,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +1000,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1091,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1185,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1276,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1370,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1461,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1555,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1646,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1740,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1829,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1923,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2031,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2193,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2359,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2510,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2676,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2829,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2999,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3150,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3316,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3473,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3635,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3786,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3952,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4124,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4303,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4454,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4622,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4822,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5066,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5216,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5384,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5485,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5659,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5760,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5906,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..baf425d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,32 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + embeddings: [], + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..9e141da 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,78 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + functions: [], + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +179,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +196,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -150,6 +223,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise<Models.Function>; /** * 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. @@ -159,7 +233,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +250,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +278,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise<Models.Function>; create( paramsOrFirst: @@ -229,6 +305,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +330,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise<Models.Function> { let params: { @@ -278,6 +356,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +387,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +413,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +439,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +521,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +532,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +643,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + runtimes: [], + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + supports: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +741,33 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +822,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +893,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -640,15 +901,16 @@ export class Functions { * @param {string} params.commands - Build Commands. * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the function deployments. - * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} params.buildSpecification - Build specification for the function deployments. + * @param {string | null} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -666,15 +928,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }): Promise<Models.Function>; /** * Update function by its unique ID. @@ -684,7 +947,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -692,15 +955,16 @@ export class Functions { * @param {string} commands - Build Commands. * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the function deployments. - * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} buildSpecification - Build specification for the function deployments. + * @param {string | null} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -719,15 +983,16 @@ export class Functions { commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, - runtimeSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, + runtimeSpecification?: string | null, deploymentRetention?: number, + interval?: number | null, ): Promise<Models.Function>; update( paramsOrFirst: @@ -745,15 +1010,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; } | string, ...rest: [ @@ -769,15 +1035,16 @@ export class Functions { string?, ProjectKeyScopes[]?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, number?, + (number | null)?, ] ): Promise<Models.Function> { let params: { @@ -794,15 +1061,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }; if ( @@ -824,15 +1092,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }; } else { params = { @@ -849,15 +1118,16 @@ export class Functions { commands: rest[9] as string, scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, + providerRepositoryId: rest[12] as string | null, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - providerBranches: rest[16] as string[], - providerPaths: rest[17] as string[], - buildSpecification: rest[18] as string, - runtimeSpecification: rest[19] as string, + providerBranches: rest[16] as string[] | null, + providerPaths: rest[17] as string[] | null, + buildSpecification: rest[18] as string | null, + runtimeSpecification: rest[19] as string | null, deploymentRetention: rest[20] as number, + interval: rest[21] as number | null, }; } @@ -883,6 +1153,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1230,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1241,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1433,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1597,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1892,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2102,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2256,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2369,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2673,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2794,59 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2858,7 @@ export class Functions { * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ @@ -2190,7 +2869,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Execution>; /** * 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. @@ -2201,7 +2880,7 @@ export class Functions { * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2213,7 +2892,7 @@ export class Functions { xpath?: string, method?: ExecutionMethod, headers?: object, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Execution>; createExecution( paramsOrFirst: @@ -2224,7 +2903,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; } | string, ...rest: [ @@ -2233,7 +2912,7 @@ export class Functions { string?, ExecutionMethod?, object?, - string?, + (string | null)?, ] ): Promise<Models.Execution> { let params: { @@ -2243,7 +2922,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -2258,7 +2937,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -2268,7 +2947,7 @@ 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 | null, }; } @@ -2315,7 +2994,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3108,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3304,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3462,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3554,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2752,27 +3581,27 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2780,28 +3609,33 @@ export class Functions { updateVariable( functionId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2812,17 +3646,17 @@ export class Functions { params = (paramsOrFirst || {}) as { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2862,7 +3696,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..ca069ee 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + localeCodes: [], + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +170,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + continents: [], + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +245,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +320,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +397,32 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + phones: [], + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +473,36 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + currencies: [], + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +553,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + languages: [], + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..2bc0b35 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,39 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + messages: [], + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,12 +137,12 @@ export class Messaging { * @param {string[]} params.targets - List of Targets IDs. * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -118,12 +155,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }): Promise<Models.Message>; /** * Create a new email message. @@ -136,12 +173,12 @@ export class Messaging { * @param {string[]} targets - List of Targets IDs. * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -155,12 +192,12 @@ export class Messaging { targets?: string[], cc?: string[], bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, + attachments?: string[] | null, draft?: boolean, html?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, + replyToEmail?: string, + replyToName?: string, ): Promise<Models.Message>; createEmail( paramsOrFirst: @@ -173,12 +210,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -189,11 +226,11 @@ export class Messaging { string[]?, string[]?, string[]?, - string[]?, - string?, - string?, + (string[] | null)?, boolean?, boolean?, + (string | null)?, + string?, string?, ] ): Promise<Models.Message> { @@ -206,12 +243,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -228,12 +265,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -245,12 +282,12 @@ export class Messaging { targets: rest[4] as string[], cc: rest[5] as string[], bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + attachments: rest[7] as string[] | null, + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string | null, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -263,11 +300,11 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; - const replyToEmail = params.replyToEmail; - const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -312,12 +349,6 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } - if (typeof replyToEmail !== 'undefined') { - apiPayload['replyToEmail'] = replyToEmail; - } - if (typeof replyToName !== 'undefined') { - apiPayload['replyToName'] = replyToName; - } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -327,6 +358,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -335,7 +372,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,126 +401,126 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.subject - Email Subject. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {string[]} params.cc - Array of target IDs to be added as CC. - * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} params.draft - Is message a draft - * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.subject - Email Subject. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {boolean | null} params.html - Is content of type HTML + * @param {string[] | null} params.cc - Array of target IDs to be added as CC. + * @param {string[] | null} params.bcc - Array of target IDs to be added as BCC. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.Message>; /** * 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} subject - Email Subject. - * @param {string} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {string[]} cc - Array of target IDs to be added as CC. - * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} draft - Is message a draft - * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} subject - Email Subject. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {boolean | null} html - Is content of type HTML + * @param {string[] | null} cc - Array of target IDs to be added as CC. + * @param {string[] | null} bcc - Array of target IDs to be added as BCC. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateEmail( messageId: string, - subject?: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - cc?: string[], - bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, - draft?: boolean, - html?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + subject?: string | null, + content?: string | null, + draft?: boolean | null, + html?: boolean | null, + cc?: string[] | null, + bcc?: string[] | null, + scheduledAt?: string | null, + attachments?: string[] | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.Message>; updateEmail( paramsOrFirst: | { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string?, - string?, - boolean?, - boolean?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.Message> { let params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -472,53 +530,53 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - subject: rest[0] as string, - content: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - cc: rest[5] as string[], - bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + subject: rest[3] as string | null, + content: rest[4] as string | null, + draft: rest[5] as boolean | null, + html: rest[6] as boolean | null, + cc: rest[7] as string[] | null, + bcc: rest[8] as string[] | null, + scheduledAt: rest[9] as string | null, + attachments: rest[10] as string[] | null, + replyToEmail: rest[11] as string | null, + replyToName: rest[12] as string | null, }; } const messageId = params.messageId; - const subject = params.subject; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; const cc = params.cc; const bcc = params.bcc; + const scheduledAt = params.scheduledAt; const attachments = params.attachments; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - const draft = params.draft; - const html = params.html; - const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -529,12 +587,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof subject !== 'undefined') { - apiPayload['subject'] = subject; - } - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -544,12 +596,27 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof subject !== 'undefined') { + apiPayload['subject'] = subject; + } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + if (typeof draft !== 'undefined') { + apiPayload['draft'] = draft; + } + if (typeof html !== 'undefined') { + apiPayload['html'] = html; + } if (typeof cc !== 'undefined') { apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { apiPayload['bcc'] = bcc; } + if (typeof scheduledAt !== 'undefined') { + apiPayload['scheduledAt'] = scheduledAt; + } if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } @@ -559,15 +626,6 @@ export class Messaging { if (typeof replyToName !== 'undefined') { apiPayload['replyToName'] = replyToName; } - if (typeof draft !== 'undefined') { - apiPayload['draft'] = draft; - } - if (typeof html !== 'undefined') { - apiPayload['html'] = html; - } - if (typeof scheduledAt !== 'undefined') { - apiPayload['scheduledAt'] = scheduledAt; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -576,7 +634,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -588,7 +667,7 @@ export class Messaging { * @param {string[]} params.topics - List of Topic IDs. * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional key-value pair data for push notification. + * @param {object | null} params.data - Additional key-value pair data for push notification. * @param {string} params.action - Action for push notification. * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. @@ -597,7 +676,7 @@ export class Messaging { * @param {string} params.tag - Tag for push notification. Available only for Android Platform. * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -612,7 +691,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -621,7 +700,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -636,7 +715,7 @@ export class Messaging { * @param {string[]} topics - List of Topic IDs. * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional key-value pair data for push notification. + * @param {object | null} data - Additional key-value pair data for push notification. * @param {string} action - Action for push notification. * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. @@ -645,7 +724,7 @@ export class Messaging { * @param {string} tag - Tag for push notification. Available only for Android Platform. * @param {number} badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -661,7 +740,7 @@ export class Messaging { topics?: string[], users?: string[], targets?: string[], - data?: object, + data?: object | null, action?: string, image?: string, icon?: string, @@ -670,7 +749,7 @@ export class Messaging { tag?: string, badge?: number, draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, @@ -685,7 +764,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -694,7 +773,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -707,7 +786,7 @@ export class Messaging { string[]?, string[]?, string[]?, - object?, + (object | null)?, string?, string?, string?, @@ -716,7 +795,7 @@ export class Messaging { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, MessagePriority?, @@ -730,7 +809,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -739,7 +818,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -758,7 +837,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -767,7 +846,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -781,7 +860,7 @@ export class Messaging { topics: rest[2] as string[], users: rest[3] as string[], targets: rest[4] as string[], - data: rest[5] as object, + data: rest[5] as object | null, action: rest[6] as string, image: rest[7] as string, icon: rest[8] as string, @@ -790,7 +869,7 @@ export class Messaging { tag: rest[11] as string, badge: rest[12] as number, draft: rest[13] as boolean, - scheduledAt: rest[14] as string, + scheduledAt: rest[14] as string | null, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, @@ -893,7 +972,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -901,168 +1001,168 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.title - Title for push notification. - * @param {string} params.body - Body for push notification. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional Data for push notification. - * @param {string} params.action - Action for push notification. - * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} params.color - Color for push notification. Available only for Android platforms. - * @param {string} params.tag - Tag for push notification. Available only for Android platforms. - * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.title - Title for push notification. + * @param {string | null} params.body - Body for push notification. + * @param {object | null} params.data - Additional Data for push notification. + * @param {string | null} params.action - Action for push notification. + * @param {string | null} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} params.color - Color for push notification. Available only for Android platforms. + * @param {string | null} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }): Promise<Models.Message>; /** * 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} title - Title for push notification. - * @param {string} body - Body for push notification. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional Data for push notification. - * @param {string} action - Action for push notification. - * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} color - Color for push notification. Available only for Android platforms. - * @param {string} tag - Tag for push notification. Available only for Android platforms. - * @param {number} badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} title - Title for push notification. + * @param {string | null} body - Body for push notification. + * @param {object | null} data - Additional Data for push notification. + * @param {string | null} action - Action for push notification. + * @param {string | null} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} color - Color for push notification. Available only for Android platforms. + * @param {string | null} tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePush( 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, - channelId?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + title?: string | null, + body?: string | null, + data?: object | null, + action?: string | null, + image?: string | null, + icon?: string | null, + sound?: string | null, + color?: string | null, + tag?: string | null, + badge?: number | null, + draft?: boolean | null, + scheduledAt?: string | null, + contentAvailable?: boolean | null, + critical?: boolean | null, + priority?: MessagePriority | null, + channelId?: string | null, ): Promise<Models.Message>; updatePush( 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - object?, - string?, - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string?, - boolean?, - boolean?, - MessagePriority?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (object | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (MessagePriority | null)?, + (string | null)?, ] ): Promise<Models.Message> { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; if ( @@ -1072,57 +1172,57 @@ export class Messaging { ) { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - title: rest[0] as string, - body: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - data: rest[5] as object, - action: rest[6] as string, - image: rest[7] as string, - icon: rest[8] as string, - sound: rest[9] as string, - color: rest[10] as string, - tag: rest[11] as string, - badge: rest[12] as number, - draft: rest[13] as boolean, - scheduledAt: rest[14] as string, - contentAvailable: rest[15] as boolean, - critical: rest[16] as boolean, - priority: rest[17] as MessagePriority, - channelId: rest[18] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + title: rest[3] as string | null, + body: rest[4] as string | null, + data: rest[5] as object | null, + action: rest[6] as string | null, + image: rest[7] as string | null, + icon: rest[8] as string | null, + sound: rest[9] as string | null, + color: rest[10] as string | null, + tag: rest[11] as string | null, + badge: rest[12] as number | null, + draft: rest[13] as boolean | null, + scheduledAt: rest[14] as string | null, + contentAvailable: rest[15] as boolean | null, + critical: rest[16] as boolean | null, + priority: rest[17] as MessagePriority | null, + channelId: rest[18] as string | null, }; } const messageId = params.messageId; - const title = params.title; - const body = params.body; const topics = params.topics; const users = params.users; const targets = params.targets; + const title = params.title; + const body = params.body; const data = params.data; const action = params.action; const image = params.image; @@ -1147,12 +1247,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof title !== 'undefined') { - apiPayload['title'] = title; - } - if (typeof body !== 'undefined') { - apiPayload['body'] = body; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1162,6 +1256,12 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof title !== 'undefined') { + apiPayload['title'] = title; + } + if (typeof body !== 'undefined') { + apiPayload['body'] = body; + } if (typeof data !== 'undefined') { apiPayload['data'] = data; } @@ -1212,7 +1312,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1224,7 +1345,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. @@ -1236,7 +1357,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1247,7 +1368,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1259,7 +1380,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSms( paramsOrFirst: @@ -1270,10 +1391,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1282,7 +1410,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1297,7 +1425,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1307,7 +1435,7 @@ 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 | null, }; } @@ -1359,7 +1487,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1371,7 +1520,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -1382,7 +1531,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1393,7 +1542,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1405,7 +1554,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSMS( paramsOrFirst: @@ -1416,10 +1565,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1428,7 +1584,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1443,7 +1599,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1453,7 +1609,7 @@ 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 | null, }; } @@ -1505,7 +1661,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1513,71 +1690,78 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ updateSms(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSms( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSms( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1587,30 +1771,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1623,9 +1807,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1635,6 +1816,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1649,7 +1833,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1657,70 +1862,77 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSMS(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSMS( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSMS( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1730,30 +1942,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1766,9 +1978,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1778,6 +1987,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1792,7 +2004,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2082,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2240,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2349,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + providers: [], + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2078,7 +2392,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. @@ -2091,7 +2405,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2103,7 +2417,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2116,7 +2430,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createApnsProvider( paramsOrFirst: @@ -2128,7 +2442,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2138,7 +2452,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2149,7 +2463,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2165,7 +2479,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2176,7 +2490,7 @@ 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 | null, }; } @@ -2230,7 +2544,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2243,7 +2576,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -2255,7 +2588,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2267,7 +2600,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2280,7 +2613,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createAPNSProvider( paramsOrFirst: @@ -2292,7 +2625,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2302,7 +2635,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2313,7 +2646,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2329,7 +2662,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2340,7 +2673,7 @@ 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 | null, }; } @@ -2394,7 +2727,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2402,12 +2754,12 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. @@ -2415,24 +2767,24 @@ export class Messaging { updateApnsProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2440,45 +2792,45 @@ export class Messaging { updateApnsProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateApnsProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2489,23 +2841,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2556,7 +2908,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2564,36 +2935,36 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAPNSProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2601,45 +2972,45 @@ export class Messaging { updateAPNSProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateAPNSProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2650,23 +3021,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2717,7 +3088,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2725,27 +3115,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createAppwriteProvider(params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Create a new Appwrite push provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2753,28 +3143,33 @@ export class Messaging { createAppwriteProvider( providerId: string, name: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; createAppwriteProvider( paramsOrFirst: | { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2785,17 +3180,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2837,7 +3232,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,27 +3259,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAppwriteProvider(params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Update an Appwrite push provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2873,28 +3287,33 @@ export class Messaging { updateAppwriteProvider( providerId: string, name?: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; updateAppwriteProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2905,17 +3324,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2954,7 +3373,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2962,8 +3400,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. @@ -2971,16 +3409,16 @@ export class Messaging { createFcmProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2988,25 +3426,25 @@ export class Messaging { createFcmProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFcmProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3017,15 +3455,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3063,7 +3501,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3071,24 +3528,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFCMProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3096,25 +3553,25 @@ export class Messaging { createFCMProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFCMProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3125,15 +3582,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3171,7 +3628,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,8 +3655,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. @@ -3188,16 +3664,16 @@ export class Messaging { updateFcmProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3205,25 +3681,25 @@ export class Messaging { updateFcmProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFcmProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3234,15 +3710,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3277,7 +3753,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3285,24 +3780,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFCMProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3310,25 +3805,25 @@ export class Messaging { updateFCMProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFCMProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3339,15 +3834,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3382,7 +3877,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3392,12 +3906,12 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.isEuRegion - Set as EU region. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3406,12 +3920,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Mailgun provider. @@ -3420,12 +3934,12 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean | null} isEuRegion - Set as EU region. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3435,12 +3949,12 @@ export class Messaging { name: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, + isEuRegion?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMailgunProvider( paramsOrFirst: @@ -3449,24 +3963,24 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -3474,12 +3988,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3492,12 +4006,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3505,12 +4019,12 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, + isEuRegion: rest[3] as boolean | null, fromName: rest[4] as string, 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 | null, }; } @@ -3572,7 +4086,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3582,8 +4115,8 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3596,8 +4129,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3610,8 +4143,8 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} isEuRegion - Set as EU region. + * @param {boolean | null} enabled - Set as enabled. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3625,8 +4158,8 @@ export class Messaging { name?: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, - enabled?: boolean, + isEuRegion?: boolean | null, + enabled?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, @@ -3639,8 +4172,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3651,8 +4184,8 @@ export class Messaging { string?, string?, string?, - boolean?, - boolean?, + (boolean | null)?, + (boolean | null)?, string?, string?, string?, @@ -3664,8 +4197,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3682,8 +4215,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3695,8 +4228,8 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, - enabled: rest[4] as boolean, + isEuRegion: rest[3] as boolean | null, + enabled: rest[4] as boolean | null, fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, @@ -3759,7 +4292,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3770,7 +4322,7 @@ export class Messaging { * @param {string} params.templateId - Msg91 template ID * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3780,7 +4332,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new MSG91 provider. @@ -3790,7 +4342,7 @@ export class Messaging { * @param {string} templateId - Msg91 template ID * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3801,7 +4353,7 @@ export class Messaging { templateId?: string, senderId?: string, authKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMsg91Provider( paramsOrFirst: @@ -3811,10 +4363,10 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -3822,7 +4374,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3836,7 +4388,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3845,7 +4397,7 @@ 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 | null, }; } @@ -3891,7 +4443,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3899,7 +4470,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.templateId - Msg91 template ID. * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. @@ -3909,7 +4480,7 @@ export class Messaging { updateMsg91Provider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3919,7 +4490,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} templateId - Msg91 template ID. * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. @@ -3930,7 +4501,7 @@ export class Messaging { updateMsg91Provider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, templateId?: string, senderId?: string, authKey?: string, @@ -3940,18 +4511,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3965,7 +4536,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3974,7 +4545,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, templateId: rest[2] as string, senderId: rest[3] as string, authKey: rest[4] as string, @@ -4020,7 +4591,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4033,7 +4623,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4045,7 +4635,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Resend provider. @@ -4057,7 +4647,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4070,7 +4660,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createResendProvider( paramsOrFirst: @@ -4082,7 +4672,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4092,7 +4682,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4103,7 +4693,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4119,7 +4709,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4130,7 +4720,7 @@ 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 | null, }; } @@ -4184,7 +4774,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4192,7 +4801,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Resend API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4204,7 +4813,7 @@ export class Messaging { updateResendProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4216,7 +4825,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Resend API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4229,7 +4838,7 @@ export class Messaging { updateResendProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4241,7 +4850,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4251,7 +4860,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4262,7 +4871,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4278,7 +4887,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4289,7 +4898,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4345,7 +4954,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4358,7 +4986,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4370,7 +4998,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Sendgrid provider. @@ -4382,7 +5010,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4395,7 +5023,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSendgridProvider( paramsOrFirst: @@ -4407,7 +5035,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4417,7 +5045,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4428,7 +5056,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4444,7 +5072,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4455,7 +5083,7 @@ 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 | null, }; } @@ -4509,7 +5137,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4517,7 +5164,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Sendgrid API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4529,7 +5176,7 @@ export class Messaging { updateSendgridProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4541,7 +5188,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Sendgrid API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4554,7 +5201,7 @@ export class Messaging { updateSendgridProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4566,7 +5213,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4576,7 +5223,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4587,7 +5234,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4603,7 +5250,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4614,7 +5261,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4670,7 +5317,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4685,7 +5351,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4699,7 +5365,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Amazon SES provider. @@ -4713,7 +5379,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4728,7 +5394,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSesProvider( paramsOrFirst: @@ -4742,7 +5408,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4754,7 +5420,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4767,7 +5433,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4785,7 +5451,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4798,7 +5464,7 @@ 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 | null, }; } @@ -4860,7 +5526,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4868,7 +5553,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accessKey - AWS access key ID. * @param {string} params.secretKey - AWS secret access key. * @param {string} params.region - AWS region, for example us-east-1. @@ -4882,7 +5567,7 @@ export class Messaging { updateSesProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4896,7 +5581,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accessKey - AWS access key ID. * @param {string} secretKey - AWS secret access key. * @param {string} region - AWS region, for example us-east-1. @@ -4911,7 +5596,7 @@ export class Messaging { updateSesProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accessKey?: string, secretKey?: string, region?: string, @@ -4925,7 +5610,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4937,7 +5622,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4950,7 +5635,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4968,7 +5653,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4981,7 +5666,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accessKey: rest[2] as string, secretKey: rest[3] as string, region: rest[4] as string, @@ -5047,7 +5732,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5066,7 +5770,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. @@ -5085,7 +5789,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5103,7 +5807,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5122,7 +5826,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSmtpProvider( paramsOrFirst: @@ -5140,7 +5844,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5156,7 +5860,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5173,7 +5877,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5195,7 +5899,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5212,7 +5916,7 @@ 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 | null, }; } @@ -5293,7 +5997,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5312,7 +6035,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5330,7 +6053,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5348,7 +6071,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5367,7 +6090,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSMTPProvider( paramsOrFirst: @@ -5385,7 +6108,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5401,7 +6124,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5418,7 +6141,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5440,7 +6163,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5457,7 +6180,7 @@ 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 | null, }; } @@ -5538,7 +6261,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5547,17 +6289,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. @@ -5566,17 +6308,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5584,17 +6326,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5603,17 +6345,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSmtpProvider( paramsOrFirst: @@ -5621,50 +6363,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5676,34 +6418,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -5778,7 +6520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5787,17 +6548,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5805,17 +6566,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5823,17 +6584,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5842,17 +6603,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSMTPProvider( paramsOrFirst: @@ -5860,50 +6621,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5915,34 +6676,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -6017,7 +6778,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6028,7 +6808,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6038,7 +6818,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Telesign provider. @@ -6048,7 +6828,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6059,7 +6839,7 @@ export class Messaging { from?: string, customerId?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTelesignProvider( paramsOrFirst: @@ -6069,10 +6849,10 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6080,7 +6860,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6094,7 +6874,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6103,7 +6883,7 @@ 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 | null, }; } @@ -6149,7 +6929,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6157,7 +6956,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. * @param {string} params.from - Sender number. @@ -6167,7 +6966,7 @@ export class Messaging { updateTelesignProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6177,7 +6976,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. * @param {string} from - Sender number. @@ -6188,7 +6987,7 @@ export class Messaging { updateTelesignProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, customerId?: string, apiKey?: string, from?: string, @@ -6198,18 +6997,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6223,7 +7022,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6232,7 +7031,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, customerId: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6278,7 +7077,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6289,7 +7107,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6299,7 +7117,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Textmagic provider. @@ -6309,7 +7127,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6320,7 +7138,7 @@ export class Messaging { from?: string, username?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTextmagicProvider( paramsOrFirst: @@ -6330,10 +7148,10 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6341,7 +7159,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6355,7 +7173,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6364,7 +7182,7 @@ 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 | null, }; } @@ -6410,7 +7228,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6418,7 +7255,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. * @param {string} params.from - Sender number. @@ -6428,7 +7265,7 @@ export class Messaging { updateTextmagicProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6438,7 +7275,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. * @param {string} from - Sender number. @@ -6449,7 +7286,7 @@ export class Messaging { updateTextmagicProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, username?: string, apiKey?: string, from?: string, @@ -6459,18 +7296,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6484,7 +7321,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6493,7 +7330,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, username: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6539,7 +7376,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6550,7 +7406,7 @@ export class Messaging { * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6560,7 +7416,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Twilio provider. @@ -6570,7 +7426,7 @@ export class Messaging { * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6581,7 +7437,7 @@ export class Messaging { from?: string, accountSid?: string, authToken?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTwilioProvider( paramsOrFirst: @@ -6591,10 +7447,10 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6602,7 +7458,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6616,7 +7472,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6625,7 +7481,7 @@ 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 | null, }; } @@ -6671,7 +7527,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6679,7 +7554,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6689,7 +7564,7 @@ export class Messaging { updateTwilioProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6699,7 +7574,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6710,7 +7585,7 @@ export class Messaging { updateTwilioProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accountSid?: string, authToken?: string, from?: string, @@ -6720,18 +7595,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6745,7 +7620,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6754,7 +7629,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accountSid: rest[2] as string, authToken: rest[3] as string, from: rest[4] as string, @@ -6800,7 +7675,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6811,7 +7705,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6821,7 +7715,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Vonage provider. @@ -6831,7 +7725,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6842,7 +7736,7 @@ export class Messaging { from?: string, apiKey?: string, apiSecret?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createVonageProvider( paramsOrFirst: @@ -6852,10 +7746,10 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6863,7 +7757,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6877,7 +7771,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6886,7 +7780,7 @@ 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 | null, }; } @@ -6932,7 +7826,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6940,7 +7853,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. * @param {string} params.from - Sender number. @@ -6950,7 +7863,7 @@ export class Messaging { updateVonageProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -6960,7 +7873,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. * @param {string} from - Sender number. @@ -6971,7 +7884,7 @@ export class Messaging { updateVonageProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, apiSecret?: string, from?: string, @@ -6981,18 +7894,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7006,7 +7919,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7015,7 +7928,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, apiSecret: rest[3] as string, from: rest[4] as string, @@ -7061,7 +7974,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +8050,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8204,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + topics: [], + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7262,8 +8243,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ @@ -7271,8 +8252,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Create a new topic. @@ -7280,8 +8261,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7290,8 +8271,8 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, - expiry?: number, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; createTopic( paramsOrFirst: @@ -7299,18 +8280,18 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [string?, string[]?, (number | null)?, (number | null)?] ): Promise<Models.Topic> { let params: { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7322,16 +8303,16 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7373,7 +8354,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7438,58 +8457,63 @@ export class Messaging { * * * @param {string} params.topicId - Topic ID. - * @param {string} params.name - Topic Name. - * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} params.name - Topic Name. + * @param {string[] | null} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Update a topic by its unique ID. * * * @param {string} topicId - Topic ID. - * @param {string} name - Topic Name. - * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} name - Topic Name. + * @param {string[] | null} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. */ updateTopic( topicId: string, - name?: string, - subscribe?: string[], - qos?: number, - expiry?: number, + name?: string | null, + subscribe?: string[] | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; updateTopic( paramsOrFirst: | { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [ + (string | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Topic> { let params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7499,18 +8523,18 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, - name: rest[0] as string, - subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + name: rest[0] as string | null, + subscribe: rest[1] as string[] | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7549,7 +8573,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8750,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + subscribers: [], + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8875,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8972,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..41c0a19 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,74 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mongo { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mongo { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mongo { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mongo { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mongo { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,40 +2620,59 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2045,12 +2681,12 @@ export class Mongo { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2077,7 +2713,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2861,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2177,21 +2925,21 @@ export class Mongo { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2199,18 +2947,22 @@ export class Mongo { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2221,13 +2973,13 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2263,7 +3015,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3175,37 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3262,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3332,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,7 +3477,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2605,27 +3514,27 @@ export class Mongo { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2633,28 +3542,28 @@ export class Mongo { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -2665,17 +3574,17 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -2714,7 +3623,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3717,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3790,52 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +3913,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..582b5ba 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,74 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mysql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mysql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mysql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mysql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2620,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2011,24 +2647,24 @@ export class Mysql { * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** * 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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Mysql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,40 +2747,68 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2153,12 +2817,12 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2185,7 +2849,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2997,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2285,21 +3061,21 @@ export class Mysql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2307,18 +3083,22 @@ export class Mysql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2329,13 +3109,13 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2371,7 +3151,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3311,37 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3398,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,97 +3468,118 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2689,26 +3589,26 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2763,7 +3663,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3741,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,7 +3886,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2944,27 +3923,27 @@ export class Mysql { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2972,28 +3951,28 @@ export class Mysql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -3004,17 +3983,17 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -3053,7 +4032,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4126,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4199,52 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4322,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..84e0c31 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -347,9 +377,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -365,9 +395,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -383,9 +413,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -402,9 +432,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -420,9 +450,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -436,9 +466,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, string?, ] @@ -453,9 +483,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -476,9 +506,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -493,9 +523,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2DeviceAuthorization>; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2DeviceAuthorization>; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise<Models.Oauth2DeviceAuthorization> { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + organizations: [], + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -999,9 +1140,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1016,9 +1157,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2PAR>; /** @@ -1033,9 +1174,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1051,9 +1192,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2PAR>; createPAR( @@ -1068,9 +1209,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1083,9 +1224,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, ] ): Promise<Models.Oauth2PAR> { @@ -1099,9 +1240,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1120,9 +1261,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1136,9 +1277,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1363,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1457,32 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1540,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1671,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1494,7 +1685,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2Token>; /** @@ -1508,7 +1699,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1523,7 +1714,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2Token>; createToken( @@ -1537,7 +1728,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1740,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise<Models.Oauth2Token> { @@ -1562,7 +1753,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1771,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1784,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1846,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..3ea45e7 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +330,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,40 +407,64 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. */ updateInstallation( installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: - { installationId: string; authorizationDetails?: string } | string, - ...rest: [string?] + | { installationId: string; authorizationDetails?: string | null } + | string, + ...rest: [(string | null)?] ): Promise<Models.AppInstallation> { - let params: { installationId: string; authorizationDetails?: string }; + let params: { + installationId: string; + authorizationDetails?: string | null; + }; if ( paramsOrFirst && @@ -345,12 +473,12 @@ export class Organization { ) { params = (paramsOrFirst || {}) as { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string, + authorizationDetails: rest[0] as string | null, }; } @@ -377,7 +505,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +660,44 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +824,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +905,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1007,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1168,92 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1340,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1469,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1616,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1827,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1964,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2052,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1441,7 +2082,7 @@ export class Organization { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -1450,7 +2091,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -1459,7 +2100,7 @@ export class Organization { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1469,7 +2110,7 @@ export class Organization { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateProjectKey( paramsOrFirst: @@ -1478,17 +2119,17 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { projectId: string; keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -1501,7 +2142,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } else { params = { @@ -1509,7 +2150,7 @@ export class Organization { keyId: rest[0] as string, name: rest[1] as string, scopes: rest[2] as ProjectKeyScopes[], - expire: rest[3] as string, + expire: rest[3] as string | null, }; } @@ -1553,7 +2194,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..881da09 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,74 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Postgresql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Postgresql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Postgresql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Postgresql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2620,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2011,24 +2647,24 @@ export class Postgresql { * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** * 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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Postgresql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,7 +2747,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2834,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + metadata: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2937,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,40 +3070,96 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2365,12 +3168,12 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2397,7 +3200,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3348,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2497,21 +3412,21 @@ export class Postgresql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2519,18 +3434,22 @@ export class Postgresql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2541,13 +3460,13 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2583,7 +3502,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3662,37 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3749,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,97 +3819,118 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2901,26 +3940,26 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2975,7 +4014,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4092,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,7 +4237,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3156,27 +4274,27 @@ export class Postgresql { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3184,28 +4302,28 @@ export class Postgresql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -3216,17 +4334,17 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -3265,7 +4383,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4477,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4550,52 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4673,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..edc7fe1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,35 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + presences: [], + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +176,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +330,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +493,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..586a6c4 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +148,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -81,7 +160,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -144,7 +223,719 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.ProjectList>; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise<Models.ProjectList>; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.ProjectList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + getEnvironment(params: { environmentId: string }): Promise<Models.Project>; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise<Models.Project>; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<Models.Project> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -209,7 +1000,38 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +1114,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +1185,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -352,7 +1214,7 @@ export class Project { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -360,7 +1222,7 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -368,7 +1230,7 @@ export class Project { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -377,7 +1239,7 @@ export class Project { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateKey( paramsOrFirst: @@ -385,16 +1247,16 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -406,14 +1268,14 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } 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 | null, }; } @@ -452,7 +1314,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +1440,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +1582,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + mockNumbers: [], + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1676,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1827,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1962,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + providers: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -945,16 +1985,16 @@ export class Project { * @param {string} params.authorizationUrl - URL to your application with consent screen. * @param {string[]} params.scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -965,16 +2005,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }): Promise<Models.Project>; @@ -985,16 +2025,16 @@ export class Project { * @param {string} authorizationUrl - URL to your application with consent screen. * @param {string[]} scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -1006,16 +2046,16 @@ export class Project { authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], - accessTokenDuration?: number, - refreshTokenDuration?: number, - publicAccessTokenDuration?: number, - publicRefreshTokenDuration?: number, - installationAccessTokenDuration?: number, - confidentialPkce?: boolean, + accessTokenDuration?: number | null, + refreshTokenDuration?: number | null, + publicAccessTokenDuration?: number | null, + publicRefreshTokenDuration?: number | null, + installationAccessTokenDuration?: number | null, + confidentialPkce?: boolean | null, verificationUrl?: string, - userCodeLength?: number, + userCodeLength?: number | null, userCodeFormat?: string, - deviceCodeDuration?: number, + deviceCodeDuration?: number | null, defaultScopes?: string[], installationScopes?: string[], ): Promise<Models.Project>; @@ -1026,16 +2066,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; } @@ -1044,16 +2084,16 @@ export class Project { string?, string[]?, string[]?, - number?, - number?, - number?, - number?, - number?, - boolean?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, string?, - number?, + (number | null)?, string?, - number?, + (number | null)?, string[]?, string[]?, ] @@ -1063,16 +2103,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1087,16 +2127,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1106,16 +2146,16 @@ export class Project { authorizationUrl: rest[0] as string, scopes: rest[1] as string[], authorizationDetailsTypes: rest[2] as string[], - accessTokenDuration: rest[3] as number, - refreshTokenDuration: rest[4] as number, - publicAccessTokenDuration: rest[5] as number, - publicRefreshTokenDuration: rest[6] as number, - installationAccessTokenDuration: rest[7] as number, - confidentialPkce: rest[8] as boolean, + accessTokenDuration: rest[3] as number | null, + refreshTokenDuration: rest[4] as number | null, + publicAccessTokenDuration: rest[5] as number | null, + publicRefreshTokenDuration: rest[6] as number | null, + installationAccessTokenDuration: rest[7] as number | null, + confidentialPkce: rest[8] as boolean | null, verificationUrl: rest[9] as string, - userCodeLength: rest[10] as number, + userCodeLength: rest[10] as number | null, userCodeFormat: rest[11] as string, - deviceCodeDuration: rest[12] as number, + deviceCodeDuration: rest[12] as number | null, defaultScopes: rest[13] as string[], installationScopes: rest[14] as string[], }; @@ -1208,48 +2248,127 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Amazon configuration. * - * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} */ updateOAuth2Amazon(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Amazon>; /** * Update the project OAuth2 Amazon configuration. * - * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Amazon( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Amazon>; updateOAuth2Amazon( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Amazon> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1259,15 +2378,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1293,76 +2412,99 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Apple configuration. * - * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} */ updateOAuth2Apple(params?: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Apple>; /** * Update the project OAuth2 Apple configuration. * - * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Apple( - serviceId?: string, - keyId?: string, - teamId?: string, - p8File?: string, - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + serviceId?: string | null, + keyId?: string | null, + teamId?: string | null, + p8File?: string | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Apple>; updateOAuth2Apple( paramsOrFirst?: | { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Apple> { let params: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -1372,23 +2514,23 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - serviceId: paramsOrFirst as string, - keyId: rest[0] as string, - teamId: rest[1] as string, - p8File: rest[2] as string, - nativeClientIds: rest[3] as string[], - enabled: rest[4] as boolean, - nativeEnabled: rest[5] as boolean, + serviceId: paramsOrFirst as string | null, + keyId: rest[0] as string | null, + teamId: rest[1] as string | null, + p8File: rest[2] as string | null, + enabled: rest[3] as boolean | null, + nativeClientIds: rest[4] as string[] | null, + nativeEnabled: rest[5] as boolean | null, }; } @@ -1396,8 +2538,8 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; @@ -1413,12 +2555,12 @@ export class Project { if (typeof p8File !== 'undefined') { apiPayload['p8File'] = p8File; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -1430,48 +2572,72 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} */ updateOAuth2Appwrite(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Appwrite>; /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Appwrite( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Appwrite>; updateOAuth2Appwrite( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Appwrite> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1481,15 +2647,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1515,64 +2681,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} */ updateOAuth2Auth0(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }): Promise<Models.OAuth2Auth0>; /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Auth0( - clientId?: string, - clientSecret?: string, - endpoint?: string, - prompt?: ProjectOAuth2Auth0Prompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2Auth0Prompt[] | null, ): Promise<Models.OAuth2Auth0>; updateOAuth2Auth0( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2Auth0Prompt[] | null)?, + ] ): Promise<Models.OAuth2Auth0> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; if ( @@ -1582,27 +2769,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - prompt: rest[2] as ProjectOAuth2Auth0Prompt[], - enabled: rest[3] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1614,12 +2801,12 @@ export class Project { if (typeof endpoint !== 'undefined') { apiPayload['endpoint'] = endpoint; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1628,58 +2815,76 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Authentik configuration. * - * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} */ updateOAuth2Authentik(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Authentik>; /** * Update the project OAuth2 Authentik configuration. * - * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Authentik( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Authentik>; updateOAuth2Authentik( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Authentik> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -1689,17 +2894,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -1729,48 +2934,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} */ updateOAuth2Autodesk(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Autodesk>; /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Autodesk( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Autodesk>; updateOAuth2Autodesk( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Autodesk> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1780,15 +3006,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1814,44 +3040,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} */ updateOAuth2Bitbucket(params?: { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitbucket>; /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitbucket( - key?: string, - secret?: string, - enabled?: boolean, + key?: string | null, + secret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitbucket>; updateOAuth2Bitbucket( paramsOrFirst?: - { key?: string; secret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitbucket> { - let params: { key?: string; secret?: string; enabled?: boolean }; + let params: { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -1860,15 +3111,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }; } else { params = { - key: paramsOrFirst as string, - secret: rest[0] as string, - enabled: rest[1] as boolean, + key: paramsOrFirst as string | null, + secret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1894,48 +3145,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitly configuration. * - * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} */ updateOAuth2Bitly(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitly>; /** * Update the project OAuth2 Bitly configuration. * - * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitly( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitly>; updateOAuth2Bitly( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitly> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1945,15 +3216,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1979,48 +3250,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Box configuration. * - * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} */ updateOAuth2Box(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Box>; /** * Update the project OAuth2 Box configuration. * - * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Box( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Box>; updateOAuth2Box( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Box> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2030,15 +3321,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2064,48 +3355,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} */ updateOAuth2Cloudflare(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Cloudflare>; /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Cloudflare( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Cloudflare>; updateOAuth2Cloudflare( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Cloudflare> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2115,15 +3426,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2149,44 +3460,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} */ updateOAuth2Dailymotion(params?: { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dailymotion>; /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dailymotion( - apiKey?: string, - apiSecret?: string, - enabled?: boolean, + apiKey?: string | null, + apiSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dailymotion>; updateOAuth2Dailymotion( paramsOrFirst?: - { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dailymotion> { - let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + let params: { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2195,15 +3531,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - apiKey: paramsOrFirst as string, - apiSecret: rest[0] as string, - enabled: rest[1] as boolean, + apiKey: paramsOrFirst as string | null, + apiSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2229,58 +3565,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Discord configuration. * - * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} */ updateOAuth2Discord(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }): Promise<Models.OAuth2Discord>; /** * Update the project OAuth2 Discord configuration. * - * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Discord( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2DiscordPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2DiscordPrompt[] | null, ): Promise<Models.OAuth2Discord>; updateOAuth2Discord( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2DiscordPrompt[] | null)?, + ] ): Promise<Models.OAuth2Discord> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; if ( @@ -2290,24 +3646,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2DiscordPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2316,12 +3672,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2330,48 +3686,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Disqus configuration. * - * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} */ updateOAuth2Disqus(params?: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Disqus>; /** * Update the project OAuth2 Disqus configuration. * - * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Disqus( - publicKey?: string, - secretKey?: string, - enabled?: boolean, + publicKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Disqus>; updateOAuth2Disqus( paramsOrFirst?: - | { publicKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Disqus> { let params: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -2381,15 +3758,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - publicKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + publicKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2415,44 +3792,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} */ updateOAuth2Dropbox(params?: { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dropbox>; /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dropbox( - appKey?: string, - appSecret?: string, - enabled?: boolean, + appKey?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dropbox>; updateOAuth2Dropbox( paramsOrFirst?: - { appKey?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dropbox> { - let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + let params: { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2461,15 +3863,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appKey: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appKey: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2495,48 +3897,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Etsy configuration. * - * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} */ updateOAuth2Etsy(params?: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Etsy>; /** * Update the project OAuth2 Etsy configuration. * - * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Etsy( - keyString?: string, - sharedSecret?: string, - enabled?: boolean, + keyString?: string | null, + sharedSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Etsy>; updateOAuth2Etsy( paramsOrFirst?: - | { keyString?: string; sharedSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Etsy> { let params: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2546,15 +3968,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - keyString: paramsOrFirst as string, - sharedSecret: rest[0] as string, - enabled: rest[1] as boolean, + keyString: paramsOrFirst as string | null, + sharedSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2580,44 +4002,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Facebook configuration. * - * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} */ updateOAuth2Facebook(params?: { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Facebook>; /** * Update the project OAuth2 Facebook configuration. * - * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Facebook( - appId?: string, - appSecret?: string, - enabled?: boolean, + appId?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Facebook>; updateOAuth2Facebook( paramsOrFirst?: - { appId?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Facebook> { - let params: { appId?: string; appSecret?: string; enabled?: boolean }; + let params: { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2626,15 +4073,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appId: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appId: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2660,48 +4107,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Figma configuration. * - * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} */ updateOAuth2Figma(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Figma>; /** * Update the project OAuth2 Figma configuration. * - * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Figma( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Figma>; updateOAuth2Figma( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Figma> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2711,15 +4178,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2745,58 +4212,74 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} */ updateOAuth2FusionAuth(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2FusionAuth>; /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2FusionAuth( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2FusionAuth>; updateOAuth2FusionAuth( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2FusionAuth> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -2806,17 +4289,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -2846,58 +4329,79 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 GitHub configuration. * - * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} */ updateOAuth2GitHub(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }): Promise<Models.OAuth2Github>; /** * Update the project OAuth2 GitHub configuration. * - * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2GitHub( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GitHubPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2GitHubPrompt[] | null, ): Promise<Models.OAuth2Github>; updateOAuth2GitHub( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2GitHubPrompt[] | null)?, + ] ): Promise<Models.OAuth2Github> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; if ( @@ -2907,24 +4411,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GitHubPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2933,12 +4437,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2947,58 +4451,75 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} */ updateOAuth2Gitlab(params?: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Gitlab>; /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Gitlab( - applicationId?: string, - secret?: string, - endpoint?: string, - enabled?: boolean, + applicationId?: string | null, + secret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Gitlab>; updateOAuth2Gitlab( paramsOrFirst?: | { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Gitlab> { let params: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -3008,17 +4529,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - applicationId: paramsOrFirst as string, - secret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + applicationId: paramsOrFirst as string | null, + secret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -3048,76 +4569,93 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Google configuration. * - * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} */ updateOAuth2Google(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Google>; /** * Update the project OAuth2 Google configuration. * - * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Google( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GooglePrompt[], - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + prompt?: ProjectOAuth2GooglePrompt[] | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Google>; updateOAuth2Google( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - ProjectOAuth2GooglePrompt[]?, - string[]?, - boolean?, - boolean?, + (string | null)?, + (ProjectOAuth2GooglePrompt[] | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Google> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -3127,29 +4665,29 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GooglePrompt[], - nativeClientIds: rest[2] as string[], - enabled: rest[3] as boolean, - nativeEnabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + prompt: rest[1] as ProjectOAuth2GooglePrompt[] | null, + enabled: rest[2] as boolean | null, + nativeClientIds: rest[3] as string[] | null, + nativeEnabled: rest[4] as boolean | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; @@ -3162,12 +4700,12 @@ export class Project { if (typeof prompt !== 'undefined') { apiPayload['prompt'] = prompt; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -3179,48 +4717,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Hugging Face configuration. * - * @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. + * @param {string | null} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} */ updateOAuth2HuggingFace(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2HuggingFace>; /** * 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. + * @param {string | null} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2HuggingFace( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2HuggingFace>; updateOAuth2HuggingFace( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2HuggingFace> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3230,15 +4791,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3264,58 +4825,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kakao configuration. * - * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} */ updateOAuth2Kakao(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }): Promise<Models.OAuth2Kakao>; /** * Update the project OAuth2 Kakao configuration. * - * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kakao( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2KakaoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2KakaoPrompt[] | null, ): Promise<Models.OAuth2Kakao>; updateOAuth2Kakao( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2KakaoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Kakao> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; if ( @@ -3325,24 +4906,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2KakaoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2KakaoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/kakao'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3351,12 +4932,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3365,64 +4946,86 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} */ updateOAuth2Keycloak(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Keycloak>; /** * Update the project OAuth2 Keycloak configuration. * - * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com - * @param {string} realmName - Keycloak realm name. For example: appwrite-realm - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Keycloak( - clientId?: string, - clientSecret?: string, - endpoint?: string, - realmName?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + realmName?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Keycloak>; updateOAuth2Keycloak( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Keycloak> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; if ( @@ -3432,19 +5035,19 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; } 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, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + realmName: rest[2] as string | null, + enabled: rest[3] as boolean | null, }; } @@ -3478,48 +5081,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kick configuration. * - * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} */ updateOAuth2Kick(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Kick>; /** * Update the project OAuth2 Kick configuration. * - * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kick( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Kick>; updateOAuth2Kick( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Kick> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3529,15 +5154,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3563,52 +5188,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} */ updateOAuth2Linkedin(params?: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Linkedin>; /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Linkedin( - clientId?: string, - primaryClientSecret?: string, - enabled?: boolean, + clientId?: string | null, + primaryClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Linkedin>; updateOAuth2Linkedin( paramsOrFirst?: | { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Linkedin> { let params: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3618,15 +5259,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + primaryClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3652,64 +5293,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} */ updateOAuth2Microsoft(params?: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }): Promise<Models.OAuth2Microsoft>; /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Microsoft( - applicationId?: string, - applicationSecret?: string, - tenant?: string, - prompt?: ProjectOAuth2MicrosoftPrompt[], - enabled?: boolean, + applicationId?: string | null, + applicationSecret?: string | null, + tenant?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2MicrosoftPrompt[] | null, ): Promise<Models.OAuth2Microsoft>; updateOAuth2Microsoft( paramsOrFirst?: | { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2MicrosoftPrompt[] | null)?, + ] ): Promise<Models.OAuth2Microsoft> { let params: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; if ( @@ -3719,27 +5381,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; } else { params = { - applicationId: paramsOrFirst as string, - applicationSecret: rest[0] as string, - tenant: rest[1] as string, - prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], - enabled: rest[3] as boolean, + applicationId: paramsOrFirst as string | null, + applicationSecret: rest[0] as string | null, + tenant: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[] | null, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3751,12 +5413,12 @@ export class Project { if (typeof tenant !== 'undefined') { apiPayload['tenant'] = tenant; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3765,52 +5427,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Notion configuration. * - * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} */ updateOAuth2Notion(params?: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Notion>; /** * Update the project OAuth2 Notion configuration. * - * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Notion( - oauthClientId?: string, - oauthClientSecret?: string, - enabled?: boolean, + oauthClientId?: string | null, + oauthClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Notion>; updateOAuth2Notion( paramsOrFirst?: | { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Notion> { let params: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3820,15 +5500,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauthClientId: paramsOrFirst as string, - oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauthClientId: paramsOrFirst as string | null, + oauthClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3854,97 +5534,113 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Oidc configuration. * - * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} */ updateOAuth2Oidc(params?: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Oidc>; /** * Update the project OAuth2 Oidc configuration. * - * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} * @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, + clientId?: string | null, + clientSecret?: string | null, + wellKnownURL?: string | null, + authorizationURL?: string | null, + tokenURL?: string | null, + userInfoURL?: string | null, + prompt?: ProjectOAuth2OidcPrompt[] | null, + maxAge?: number | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Oidc>; updateOAuth2Oidc( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - string?, - string?, - ProjectOAuth2OidcPrompt[]?, - number?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectOAuth2OidcPrompt[] | null)?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Oidc> { let params: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; if ( @@ -3954,27 +5650,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - wellKnownURL: rest[1] as string, - authorizationURL: rest[2] as string, - tokenURL: rest[3] as string, - userInfoURL: rest[4] as string, - prompt: rest[5] as ProjectOAuth2OidcPrompt[], - maxAge: rest[6] as number, - enabled: rest[7] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + wellKnownURL: rest[1] as string | null, + authorizationURL: rest[2] as string | null, + tokenURL: rest[3] as string | null, + userInfoURL: rest[4] as string | null, + prompt: rest[5] as ProjectOAuth2OidcPrompt[] | null, + maxAge: rest[6] as number | null, + enabled: rest[7] as boolean | null, }; } @@ -4024,76 +5720,97 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Okta configuration. * - * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} */ updateOAuth2Okta(params?: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }): Promise<Models.OAuth2Okta>; /** * Update the project OAuth2 Okta configuration. * - * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Okta( - clientId?: string, - clientSecret?: string, - domain?: string, - authorizationServerId?: string, - prompt?: ProjectOAuth2OktaPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + domain?: string | null, + authorizationServerId?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2OktaPrompt[] | null, ): Promise<Models.OAuth2Okta>; updateOAuth2Okta( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - ProjectOAuth2OktaPrompt[]?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2OktaPrompt[] | null)?, ] ): Promise<Models.OAuth2Okta> { let params: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; if ( @@ -4103,21 +5820,21 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - domain: rest[1] as string, - authorizationServerId: rest[2] as string, - prompt: rest[3] as ProjectOAuth2OktaPrompt[], - enabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + domain: rest[1] as string | null, + authorizationServerId: rest[2] as string | null, + enabled: rest[3] as boolean | null, + prompt: rest[4] as ProjectOAuth2OktaPrompt[] | null, }; } @@ -4125,8 +5842,8 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4141,12 +5858,12 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { apiPayload['authorizationServerId'] = authorizationServerId; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4155,48 +5872,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Paypal configuration. * - * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2Paypal(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 Paypal configuration. * - * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Paypal( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2Paypal( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4206,15 +5946,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4240,48 +5980,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2PaypalSandbox(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2PaypalSandbox( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2PaypalSandbox( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4291,15 +6051,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4325,48 +6085,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Podio configuration. * - * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} */ updateOAuth2Podio(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Podio>; /** * Update the project OAuth2 Podio configuration. * - * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Podio( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Podio>; updateOAuth2Podio( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Podio> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4376,15 +6156,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4410,48 +6190,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Resend configuration. * - * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} */ updateOAuth2Resend(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Resend>; /** * Update the project OAuth2 Resend configuration. * - * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Resend( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Resend>; updateOAuth2Resend( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Resend> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4461,15 +6261,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4495,58 +6295,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} */ updateOAuth2Salesforce(params?: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }): Promise<Models.OAuth2Salesforce>; /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Salesforce( - customerKey?: string, - customerSecret?: string, - prompt?: ProjectOAuth2SalesforcePrompt[], - enabled?: boolean, + customerKey?: string | null, + customerSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2SalesforcePrompt[] | null, ): Promise<Models.OAuth2Salesforce>; updateOAuth2Salesforce( paramsOrFirst?: | { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2SalesforcePrompt[] | null)?, + ] ): Promise<Models.OAuth2Salesforce> { let params: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; if ( @@ -4556,24 +6376,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; } else { params = { - customerKey: paramsOrFirst as string, - customerSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], - enabled: rest[2] as boolean, + customerKey: paramsOrFirst as string | null, + customerSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[] | null, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4582,12 +6402,12 @@ export class Project { if (typeof customerSecret !== 'undefined') { apiPayload['customerSecret'] = customerSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4596,48 +6416,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Slack configuration. * - * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} */ updateOAuth2Slack(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Slack>; /** * Update the project OAuth2 Slack configuration. * - * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Slack( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Slack>; updateOAuth2Slack( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Slack> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4647,15 +6488,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4681,48 +6522,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Spotify configuration. * - * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} */ updateOAuth2Spotify(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Spotify>; /** * Update the project OAuth2 Spotify configuration. * - * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Spotify( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Spotify>; updateOAuth2Spotify( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Spotify> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4732,15 +6593,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4766,48 +6627,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Stripe configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} */ updateOAuth2Stripe(params?: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Stripe>; /** * Update the project OAuth2 Stripe configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Stripe( - clientId?: string, - apiSecretKey?: string, - enabled?: boolean, + clientId?: string | null, + apiSecretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Stripe>; updateOAuth2Stripe( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Stripe> { let params: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4817,15 +6698,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + apiSecretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4851,48 +6732,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} */ updateOAuth2TikTok(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2TikTok>; /** * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TikTok( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2TikTok>; updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2TikTok> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4902,15 +6803,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4936,52 +6837,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2Tradeshift(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Tradeshift( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2Tradeshift( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4991,15 +6908,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5025,52 +6942,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2TradeshiftSandbox(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TradeshiftSandbox( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2TradeshiftSandbox( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5080,15 +7013,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5114,48 +7047,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Twitch configuration. * - * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} */ updateOAuth2Twitch(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Twitch>; /** * Update the project OAuth2 Twitch configuration. * - * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Twitch( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Twitch>; updateOAuth2Twitch( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Twitch> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5165,15 +7118,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5199,48 +7152,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Webflow configuration. * - * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} */ updateOAuth2Webflow(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Webflow>; /** * Update the project OAuth2 Webflow configuration. * - * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Webflow( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Webflow>; updateOAuth2Webflow( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Webflow> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5250,15 +7223,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5284,48 +7257,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 WordPress configuration. * - * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} */ updateOAuth2WordPress(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2WordPress>; /** * Update the project OAuth2 WordPress configuration. * - * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2WordPress( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2WordPress>; updateOAuth2WordPress( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2WordPress> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5335,15 +7328,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5369,48 +7362,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 X configuration. * - * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} */ updateOAuth2X(params?: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2X>; /** * Update the project OAuth2 X configuration. * - * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2X( - customerKey?: string, - secretKey?: string, - enabled?: boolean, + customerKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2X>; updateOAuth2X( paramsOrFirst?: - | { customerKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2X> { let params: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -5420,15 +7433,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - customerKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + customerKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5454,48 +7467,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} */ updateOAuth2Yahoo(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yahoo>; /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yahoo( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yahoo>; updateOAuth2Yahoo( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yahoo> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5505,15 +7538,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5539,48 +7572,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yandex configuration. * - * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} */ updateOAuth2Yandex(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yandex>; /** * Update the project OAuth2 Yandex configuration. * - * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yandex( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yandex>; updateOAuth2Yandex( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yandex> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5590,15 +7643,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5624,58 +7677,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoho configuration. * - * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} */ updateOAuth2Zoho(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }): Promise<Models.OAuth2Zoho>; /** * Update the project OAuth2 Zoho configuration. * - * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoho( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2ZohoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2ZohoPrompt[] | null, ): Promise<Models.OAuth2Zoho>; updateOAuth2Zoho( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2ZohoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Zoho> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; if ( @@ -5685,24 +7758,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2ZohoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5711,12 +7784,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5725,48 +7798,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoom configuration. * - * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} */ updateOAuth2Zoom(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Zoom>; /** * Update the project OAuth2 Zoom configuration. * - * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoom( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Zoom>; updateOAuth2Zoom( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Zoom> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5776,15 +7870,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5810,7 +7904,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +8191,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + platforms: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +8213,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6098,6 +8221,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise<Models.PlatformAndroid>; /** * 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. @@ -6105,6 +8229,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +8238,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise<Models.PlatformAndroid>; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +8267,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +8306,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +8317,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6191,13 +8351,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }): Promise<Models.PlatformAndroid>; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +8368,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[] | null, ): Promise<Models.PlatformAndroid>; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + }; if ( paramsOrFirst && @@ -6224,18 +8397,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[] | null, }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +8436,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +8447,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +8561,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +8674,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +8782,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +8890,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8998,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +9106,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +9223,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +9340,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +9557,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + policies: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +9628,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +9760,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +9892,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +10024,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +10223,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +10398,209 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise<Models.Project>; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise<Models.Project>; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise<Models.Project> { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +10658,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7757,38 +10740,38 @@ export class Project { * * 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. + * @param {number | null} 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<Models.Project>} */ updatePasswordHistoryPolicy(params: { - total?: number; + total?: number | null; }): Promise<Models.Project>; /** * 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. + * @param {number | null} 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<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy(total?: number | null): Promise<Models.Project>; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -7809,7 +10792,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +10924,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +11079,224 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise<Models.Project>; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise<Models.Project>; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise<Models.Project> { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +11409,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +11484,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +11616,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +11748,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,40 +11878,116 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ - updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + updateUserLimitPolicy(params: { + total?: number | null; + }): Promise<Models.Project>; /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy(total?: number | null): Promise<Models.Project>; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -8345,15 +12008,89 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +12100,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +12112,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +12130,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +12142,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +12152,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +12164,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +12280,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,104 +12435,179 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * - * @param {string} params.host - SMTP server hostname (domain) - * @param {number} params.port - SMTP server port - * @param {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} params.host - SMTP server hostname (domain) + * @param {number | null} params.port - SMTP server port + * @param {string | null} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ updateSMTP(params?: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }): Promise<Models.Project>; /** * 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. * - * @param {string} host - SMTP server hostname (domain) - * @param {number} port - SMTP server port - * @param {string} username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} host - SMTP server hostname (domain) + * @param {number | null} port - SMTP server port + * @param {string | null} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @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, + host?: string | null, + port?: number | null, + username?: string | null, + password?: string | null, + senderEmail?: string | null, + senderName?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, + secure?: ProjectSMTPSecure | null, + enabled?: boolean | null, ): Promise<Models.Project>; updateSMTP( paramsOrFirst?: | { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - number?, - string?, - string?, - string?, - string?, - string?, - string?, - ProjectSMTPSecure?, - boolean?, + (number | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectSMTPSecure | null)?, + (boolean | null)?, ] ): Promise<Models.Project> { let params: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; if ( @@ -8725,29 +12617,29 @@ export class Project { !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; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; } else { params = { - host: paramsOrFirst as string, - port: rest[0] as number, - username: rest[1] as string, - password: rest[2] as string, - senderEmail: rest[3] as string, - senderName: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, - secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean, + host: paramsOrFirst as string | null, + port: rest[0] as number | null, + username: rest[1] as string | null, + password: rest[2] as string | null, + senderEmail: rest[3] as string | null, + senderName: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, + secure: rest[7] as ProjectSMTPSecure | null, + enabled: rest[8] as boolean | null, }; } @@ -8801,7 +12693,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +12889,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + templates: [], + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8931,36 +12927,36 @@ export class Project { * * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. - * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} params.senderName - Name of the email sender. - * @param {string} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Reply to name. + * @param {string | null} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} params.senderName - Name of the email sender. + * @param {string | null} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} */ updateEmailTemplate(params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.EmailTemplate>; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} subject - Subject of the email template. Can be up to 255 characters. - * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} senderName - Name of the email sender. - * @param {string} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Reply to name. + * @param {string | null} subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} senderName - Name of the email sender. + * @param {string | null} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8968,45 +12964,45 @@ export class Project { updateEmailTemplate( templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, - subject?: string, - message?: string, - senderName?: string, - senderEmail?: string, - replyToEmail?: string, - replyToName?: string, + subject?: string | null, + message?: string | null, + senderName?: string | null, + senderEmail?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.EmailTemplate>; updateEmailTemplate( paramsOrFirst: | { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; } | ProjectEmailTemplateId, ...rest: [ ProjectEmailTemplateLocale?, - string?, - string?, - string?, - string?, - string?, - string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.EmailTemplate> { let params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -9025,23 +13021,23 @@ export class Project { params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, locale: rest[0] as ProjectEmailTemplateLocale, - subject: rest[1] as string, - message: rest[2] as string, - senderName: rest[3] as string, - senderEmail: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, + subject: rest[1] as string | null, + message: rest[2] as string | null, + senderName: rest[3] as string | null, + senderEmail: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, }; } @@ -9092,7 +13088,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +13188,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +13275,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +13416,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,58 +13490,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ updateVariable( variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.Variable> { let params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -9468,16 +13570,16 @@ export class Project { ) { params = (paramsOrFirst || {}) as { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } else { params = { variableId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean, + key: rest[0] as string | null, + value: rest[1] as string | null, + secret: rest[2] as boolean | null, }; } @@ -9512,7 +13614,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..4a9bded 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,7 +111,22 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +194,42 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + rules: [], + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +287,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +402,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +563,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +676,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +753,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +883,30 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2424cc0 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,79 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + sites: [], + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +550,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +662,47 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + frameworks: [], + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + runtimes: [], + adapters: [], + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +770,33 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +847,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -667,16 +928,16 @@ export class Sites { * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} */ @@ -695,16 +956,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }): Promise<Models.Site>; /** * Update site by its unique ID. @@ -723,16 +984,16 @@ export class Sites { * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} * @deprecated Use the object parameter style method for a better developer experience. @@ -752,16 +1013,16 @@ export class Sites { adapter?: Adapter, fallbackFile?: string, installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, runtimeSpecification?: string, deploymentRetention?: number, - scopes?: ProjectKeyScopes[], + scopes?: ProjectKeyScopes[] | null, ): Promise<Models.Site>; update( paramsOrFirst: @@ -780,16 +1041,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; } | string, ...rest: [ @@ -806,16 +1067,16 @@ export class Sites { Adapter?, string?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, string?, number?, - ProjectKeyScopes[]?, + (ProjectKeyScopes[] | null)?, ] ): Promise<Models.Site> { let params: { @@ -833,16 +1094,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; if ( @@ -865,16 +1126,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; } else { params = { @@ -892,16 +1153,16 @@ export class Sites { adapter: rest[10] as Adapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, - providerRepositoryId: rest[13] as string, + providerRepositoryId: rest[13] as string | null, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - providerBranches: rest[17] as string[], - providerPaths: rest[18] as string[], - buildSpecification: rest[19] as string, + providerBranches: rest[17] as string[] | null, + providerPaths: rest[18] as string[] | null, + buildSpecification: rest[19] as string | null, runtimeSpecification: rest[20] as string, deploymentRetention: rest[21] as number, - scopes: rest[22] as ProjectKeyScopes[], + scopes: rest[22] as ProjectKeyScopes[] | null, }; } @@ -1022,7 +1283,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1472,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1635,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1910,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2118,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2270,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2381,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2677,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2795,59 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2910,48 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3093,37 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3249,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3336,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2586,27 +3363,27 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2614,28 +3391,33 @@ export class Sites { updateVariable( siteId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2646,17 +3428,17 @@ export class Sites { params = (paramsOrFirst || {}) as { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2694,7 +3476,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..d810652 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,43 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + buckets: [], + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -101,7 +138,7 @@ export class Storage { * * @param {string} params.bucketId - 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 - Bucket name - * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -116,7 +153,7 @@ export class Storage { createBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -131,7 +168,7 @@ export class Storage { * * @param {string} bucketId - 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 - Bucket name - * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -147,7 +184,7 @@ export class Storage { createBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, @@ -162,7 +199,7 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -175,7 +212,7 @@ export class Storage { | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, number?, @@ -189,7 +226,7 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -208,7 +245,7 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -222,7 +259,7 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, maximumFileSize: rest[4] as number, @@ -296,7 +333,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +413,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,13 +446,13 @@ export class Storage { * * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.name - Bucket name - * @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 {string[] | null} 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.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -374,13 +461,13 @@ export class Storage { updateBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }): Promise<Models.Bucket>; @@ -389,13 +476,13 @@ export class Storage { * * @param {string} bucketId - Bucket unique ID. * @param {string} name - Bucket name - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -405,13 +492,13 @@ export class Storage { updateBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, - maximumFileSize?: number, + maximumFileSize?: number | null, allowedFileExtensions?: string[], - compression?: Compression, - encryption?: boolean, + compression?: Compression | null, + encryption?: boolean | null, antivirus?: boolean, transformations?: boolean, ): Promise<Models.Bucket>; @@ -420,26 +507,26 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; } | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, - number?, + (number | null)?, string[]?, - Compression?, - boolean?, + (Compression | null)?, + (boolean | null)?, boolean?, boolean?, ] @@ -447,13 +534,13 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -466,13 +553,13 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -480,13 +567,13 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, - maximumFileSize: rest[4] as number, + maximumFileSize: rest[4] as number | null, allowedFileExtensions: rest[5] as string[], - compression: rest[6] as Compression, - encryption: rest[7] as boolean, + compression: rest[6] as Compression | null, + encryption: rest[7] as boolean | null, antivirus: rest[8] as boolean, transformations: rest[9] as boolean, }; @@ -554,7 +641,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +824,45 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + files: [], + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1084,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -943,7 +1120,7 @@ export class Storage { * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.fileId - File ID. * @param {string} params.name - File name. - * @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 {string[] | null} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ @@ -951,7 +1128,7 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }): Promise<Models.File>; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -959,7 +1136,7 @@ export class Storage { * @param {string} bucketId - Bucket unique ID. * @param {string} fileId - File ID. * @param {string} name - File name. - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} * @deprecated Use the object parameter style method for a better developer experience. @@ -968,7 +1145,7 @@ export class Storage { bucketId: string, fileId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, ): Promise<Models.File>; updateFile( paramsOrFirst: @@ -976,16 +1153,16 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.File> { let params: { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; if ( @@ -997,14 +1174,14 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; } 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[] | null, }; } @@ -1038,7 +1215,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..795ed7d 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,69 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,7 +167,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -110,7 +177,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -121,7 +188,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -132,7 +199,7 @@ export class TablesDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -142,10 +209,10 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -153,7 +220,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -167,7 +234,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -176,7 +243,7 @@ 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 | null, }; } @@ -222,7 +289,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +359,42 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +462,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +542,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +616,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +722,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +870,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +942,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,9 +1002,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -712,9 +1012,9 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -722,9 +1022,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -733,9 +1033,9 @@ export class TablesDB { databaseId: string, name?: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -743,20 +1043,26 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -768,18 +1074,18 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -822,7 +1128,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,33 +1240,33 @@ export class TablesDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -918,12 +1275,12 @@ export class TablesDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -950,7 +1307,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,7 +1420,46 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + migrations: [], + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1105,7 +1557,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1658,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1327,7 +1835,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1967,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2054,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2138,52 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2287,59 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + tables: [], + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1656,11 +2348,11 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - 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 - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} params.columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} */ @@ -1668,7 +2360,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1680,11 +2372,11 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - 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 - Table 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 {string[] | null} 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} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1693,7 +2385,7 @@ export class TablesDB { databaseId: string, tableId: string, name: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, columns?: object[], @@ -1705,7 +2397,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1715,7 +2407,7 @@ export class TablesDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1726,7 +2418,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1742,7 +2434,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1753,7 +2445,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], @@ -1816,7 +2508,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2619,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1895,7 +2669,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.name - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1906,7 +2680,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1917,7 +2691,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} name - Table 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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1929,7 +2703,7 @@ export class TablesDB { databaseId: string, tableId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1940,19 +2714,26 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Table> { let params: { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1967,7 +2748,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1977,7 +2758,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -2028,7 +2809,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +3023,20 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + columns: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2212,9 +3047,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2224,9 +3059,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnBigint>; /** @@ -2237,9 +3072,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2250,9 +3085,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnBigint>; createBigIntColumn( @@ -2262,9 +3097,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -2272,9 +3107,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnBigint> { @@ -2283,9 +3118,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -2299,9 +3134,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -2310,9 +3145,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -2373,7 +3208,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,10 +3236,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} */ @@ -2396,10 +3248,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnBigint>; /** * Update a bigint column. Changing the `default` value will not update already existing rows. @@ -2409,10 +3261,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2422,10 +3274,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnBigint>; updateBigIntColumn( paramsOrFirst: @@ -2434,20 +3286,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnBigint> { let params: { @@ -2455,10 +3307,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -2471,10 +3323,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -2482,10 +3334,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -2549,7 +3401,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2560,7 +3429,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2570,7 +3439,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.ColumnBoolean>; /** @@ -2581,7 +3450,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2592,7 +3461,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.ColumnBoolean>; createBooleanColumn( @@ -2602,18 +3471,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -2627,7 +3496,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -2636,7 +3505,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -2690,7 +3559,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2700,8 +3586,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} */ @@ -2710,8 +3596,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.ColumnBoolean>; /** * Update a boolean column. Changing the `default` value will not update already existing rows. @@ -2720,8 +3606,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2731,8 +3617,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.ColumnBoolean>; updateBooleanColumn( paramsOrFirst: @@ -2741,19 +3627,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2766,8 +3658,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2775,8 +3667,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2832,7 +3724,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2842,7 +3751,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2852,7 +3761,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnDatetime>; /** @@ -2862,7 +3771,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2873,7 +3782,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnDatetime>; createDatetimeColumn( @@ -2883,18 +3792,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2908,7 +3817,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2917,7 +3826,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2971,7 +3880,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2981,8 +3907,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} */ @@ -2991,8 +3917,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnDatetime>; /** * Update a date time column. Changing the `default` value will not update already existing rows. @@ -3001,8 +3927,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3012,8 +3938,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnDatetime>; updateDatetimeColumn( paramsOrFirst: @@ -3022,19 +3948,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3047,8 +3979,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3056,8 +3988,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3113,7 +4045,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3124,7 +4073,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3134,7 +4083,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEmail>; /** @@ -3145,7 +4094,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3156,7 +4105,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEmail>; createEmailColumn( @@ -3166,18 +4115,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3191,7 +4140,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3200,7 +4149,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3253,7 +4202,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,8 +4231,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} */ @@ -3274,8 +4241,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEmail>; /** * Update an email column. Changing the `default` value will not update already existing rows. @@ -3285,8 +4252,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3296,8 +4263,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEmail>; updateEmailColumn( paramsOrFirst: @@ -3306,19 +4273,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3331,8 +4304,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3340,8 +4313,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3397,7 +4370,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3408,7 +4399,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3419,7 +4410,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEnum>; /** @@ -3430,7 +4421,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3442,7 +4433,7 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEnum>; createEnumColumn( @@ -3453,11 +4444,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3465,7 +4463,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3480,7 +4478,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3490,7 +4488,7 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -3552,7 +4550,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3564,8 +4581,8 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} */ @@ -3575,8 +4592,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEnum>; /** * Update an enum column. Changing the `default` value will not update already existing rows. @@ -3587,8 +4604,8 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3599,8 +4616,8 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEnum>; updateEnumColumn( paramsOrFirst: @@ -3610,11 +4627,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3622,8 +4646,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3637,8 +4661,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3647,8 +4671,8 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3713,7 +4737,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3724,9 +4767,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3736,9 +4779,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.ColumnFloat>; /** @@ -3749,9 +4792,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3762,9 +4805,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.ColumnFloat>; createFloatColumn( @@ -3774,9 +4817,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3784,9 +4827,9 @@ export class TablesDB { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.ColumnFloat> { @@ -3795,9 +4838,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3811,9 +4854,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3822,9 +4865,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3885,7 +4928,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3896,10 +4956,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} */ @@ -3908,10 +4968,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.ColumnFloat>; /** * Update a float column. Changing the `default` value will not update already existing rows. @@ -3921,10 +4981,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3934,10 +4994,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.ColumnFloat>; updateFloatColumn( paramsOrFirst: @@ -3946,20 +5006,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.ColumnFloat> { let params: { @@ -3967,10 +5027,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3983,10 +5043,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3994,10 +5054,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -4061,7 +5121,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4072,9 +5149,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4084,9 +5161,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnInteger>; /** @@ -4097,9 +5174,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4110,9 +5187,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnInteger>; createIntegerColumn( @@ -4122,9 +5199,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -4132,9 +5209,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnInteger> { @@ -4143,9 +5220,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -4159,9 +5236,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -4170,9 +5247,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -4234,7 +5311,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4245,10 +5339,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} */ @@ -4257,10 +5351,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnInteger>; /** * Update an integer column. Changing the `default` value will not update already existing rows. @@ -4270,10 +5364,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4283,10 +5377,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnInteger>; updateIntegerColumn( paramsOrFirst: @@ -4295,20 +5389,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnInteger> { let params: { @@ -4316,10 +5410,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -4332,10 +5426,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -4343,10 +5437,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -4410,7 +5504,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4421,7 +5532,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4431,7 +5542,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnIp>; /** @@ -4442,7 +5553,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4453,7 +5564,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnIp>; createIpColumn( @@ -4463,18 +5574,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -4488,7 +5599,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -4497,7 +5608,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -4550,7 +5661,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4561,8 +5690,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} */ @@ -4571,8 +5700,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnIp>; /** * Update an ip column. Changing the `default` value will not update already existing rows. @@ -4582,8 +5711,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4593,8 +5722,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnIp>; updateIpColumn( paramsOrFirst: @@ -4603,19 +5732,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4628,8 +5763,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4637,8 +5772,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4694,7 +5829,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4704,7 +5857,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4713,7 +5866,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnLine>; /** * Create a geometric line column. @@ -4722,7 +5875,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4732,7 +5885,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnLine>; createLineColumn( paramsOrFirst: @@ -4741,17 +5894,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4764,7 +5917,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4772,7 +5925,7 @@ export class TablesDB { 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[][] | null, }; } @@ -4820,7 +5973,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4830,8 +6000,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4840,8 +6010,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnLine>; /** * Update a line column. Changing the `default` value will not update already existing rows. @@ -4850,8 +6020,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4861,8 +6031,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnLine>; updateLineColumn( paramsOrFirst: @@ -4871,19 +6041,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4896,8 +6072,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4905,8 +6081,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4957,7 +6133,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4968,7 +6161,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -4979,7 +6172,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnLongtext>; @@ -4991,7 +6184,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5003,7 +6196,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnLongtext>; @@ -5014,19 +6207,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5041,7 +6241,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5051,7 +6251,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5110,7 +6310,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5121,8 +6338,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} */ @@ -5131,8 +6348,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnLongtext>; /** * Update a longtext column. Changing the `default` value will not update already existing rows. @@ -5142,8 +6359,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5153,8 +6370,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnLongtext>; updateLongtextColumn( paramsOrFirst: @@ -5163,19 +6380,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5188,8 +6411,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5197,8 +6420,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5254,7 +6477,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5265,7 +6505,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5276,7 +6516,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnMediumtext>; @@ -5288,7 +6528,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5300,7 +6540,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnMediumtext>; @@ -5311,19 +6551,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5338,7 +6585,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5348,7 +6595,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5407,7 +6654,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5418,8 +6682,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} */ @@ -5428,8 +6692,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnMediumtext>; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -5439,8 +6703,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5450,8 +6714,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnMediumtext>; updateMediumtextColumn( paramsOrFirst: @@ -5460,19 +6724,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5485,8 +6755,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5494,8 +6764,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5551,7 +6821,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5561,7 +6848,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5570,7 +6857,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.ColumnPoint>; /** * Create a geometric point column. @@ -5579,7 +6866,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5589,7 +6876,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.ColumnPoint>; createPointColumn( paramsOrFirst: @@ -5598,17 +6885,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -5621,7 +6908,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -5629,7 +6916,7 @@ export class TablesDB { 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[] | null, }; } @@ -5677,7 +6964,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5687,8 +6991,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5697,8 +7001,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.ColumnPoint>; /** * Update a point column. Changing the `default` value will not update already existing rows. @@ -5707,8 +7011,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5718,8 +7022,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.ColumnPoint>; updatePointColumn( paramsOrFirst: @@ -5728,19 +7032,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5753,8 +7063,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5762,8 +7072,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5814,7 +7124,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5824,7 +7151,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5833,7 +7160,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnPolygon>; /** * Create a geometric polygon column. @@ -5842,7 +7169,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5852,7 +7179,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnPolygon>; createPolygonColumn( paramsOrFirst: @@ -5861,17 +7188,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5884,7 +7211,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5892,7 +7219,7 @@ export class TablesDB { 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[][] | null, }; } @@ -5941,7 +7268,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5951,8 +7295,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5961,8 +7305,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnPolygon>; /** * Update a polygon column. Changing the `default` value will not update already existing rows. @@ -5971,8 +7315,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5982,8 +7326,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnPolygon>; updatePolygonColumn( paramsOrFirst: @@ -5992,19 +7336,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -6017,8 +7367,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -6026,8 +7376,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -6078,7 +7428,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6090,8 +7457,8 @@ export class TablesDB { * @param {string} params.relatedTableId - Related Table ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Column Key. - * @param {string} params.twoWayKey - Two Way Column Key. + * @param {string | null} params.key - Column Key. + * @param {string | null} params.twoWayKey - Two Way Column Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6102,8 +7469,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.ColumnRelationship>; /** @@ -6115,8 +7482,8 @@ export class TablesDB { * @param {string} relatedTableId - Related Table ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Column Key. - * @param {string} twoWayKey - Two Way Column Key. + * @param {string | null} key - Column Key. + * @param {string | null} twoWayKey - Two Way Column Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6128,8 +7495,8 @@ export class TablesDB { relatedTableId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.ColumnRelationship>; createRelationshipColumn( @@ -6140,8 +7507,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -6150,8 +7517,8 @@ export class TablesDB { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.ColumnRelationship> { @@ -6161,8 +7528,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -6177,8 +7544,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -6188,8 +7555,8 @@ export class TablesDB { relatedTableId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -6251,7 +7618,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6261,8 +7650,8 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. + * @param {RelationMutate | null} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} */ @@ -6270,8 +7659,8 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }): Promise<Models.ColumnRelationship>; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -6280,8 +7669,8 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. + * @param {RelationMutate | null} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6290,8 +7679,8 @@ export class TablesDB { databaseId: string, tableId: string, key: string, - onDelete?: RelationMutate, - newKey?: string, + onDelete?: RelationMutate | null, + newKey?: string | null, ): Promise<Models.ColumnRelationship>; updateRelationshipColumn( paramsOrFirst: @@ -6299,18 +7688,18 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, (RelationMutate | null)?, (string | null)?] ): Promise<Models.ColumnRelationship> { let params: { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; if ( @@ -6322,16 +7711,16 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; } 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, + onDelete: rest[2] as RelationMutate | null, + newKey: rest[3] as string | null, }; } @@ -6373,7 +7762,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6385,7 +7796,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6398,7 +7809,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnString>; @@ -6411,7 +7822,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6424,7 +7835,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnString>; @@ -6436,7 +7847,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6446,7 +7857,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6457,7 +7868,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6473,7 +7884,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6484,7 +7895,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6549,7 +7960,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6560,9 +7989,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the string column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the string column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6572,9 +8001,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnString>; /** * Update a string column. Changing the `default` value will not update already existing rows. @@ -6584,9 +8013,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the string column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the string column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6596,9 +8025,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnString>; updateStringColumn( paramsOrFirst: @@ -6607,21 +8036,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnString> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6634,9 +8070,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6644,9 +8080,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6706,7 +8142,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6717,7 +8171,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6728,7 +8182,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnText>; @@ -6740,7 +8194,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6752,7 +8206,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnText>; @@ -6763,19 +8217,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6790,7 +8251,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6800,7 +8261,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6858,7 +8319,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6869,8 +8347,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} */ @@ -6879,8 +8357,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnText>; /** * Update a text column. Changing the `default` value will not update already existing rows. @@ -6890,8 +8368,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6901,8 +8379,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnText>; updateTextColumn( paramsOrFirst: @@ -6911,19 +8389,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6936,8 +8420,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6945,8 +8429,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7002,7 +8486,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7013,7 +8514,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7023,7 +8524,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnUrl>; /** @@ -7034,7 +8535,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7045,7 +8546,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnUrl>; createUrlColumn( @@ -7055,18 +8556,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -7080,7 +8581,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -7089,7 +8590,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -7142,7 +8643,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7153,8 +8672,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} */ @@ -7163,8 +8682,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnUrl>; /** * Update an url column. Changing the `default` value will not update already existing rows. @@ -7174,8 +8693,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7185,8 +8704,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnUrl>; updateUrlColumn( paramsOrFirst: @@ -7195,19 +8714,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -7220,8 +8745,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -7229,8 +8754,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7286,7 +8811,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7298,7 +8841,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7310,7 +8853,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnVarchar>; @@ -7323,7 +8866,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7336,7 +8879,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnVarchar>; @@ -7348,7 +8891,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -7358,7 +8901,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -7369,7 +8912,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7385,7 +8928,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7396,7 +8939,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -7462,7 +9005,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7473,9 +9034,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the varchar column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the varchar column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} */ @@ -7484,9 +9045,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnVarchar>; /** * Update a varchar column. Changing the `default` value will not update already existing rows. @@ -7496,9 +9057,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the varchar column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the varchar column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7508,9 +9069,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnVarchar>; updateVarcharColumn( paramsOrFirst: @@ -7519,21 +9080,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnVarchar> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -7546,9 +9114,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -7556,9 +9124,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7618,7 +9186,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,12 +9533,43 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -7975,7 +9592,7 @@ export class TablesDB { }): Promise<Models.ColumnIndex>; /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -8109,7 +9726,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9831,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +10062,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8415,8 +10101,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -8427,8 +10113,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -8437,8 +10123,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8450,8 +10136,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8462,8 +10148,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8472,8 +10158,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -8483,8 +10169,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8499,8 +10185,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8510,8 +10196,8 @@ export class TablesDB { data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8561,7 +10247,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8570,7 +10274,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} params.rows - Array of rows data as JSON objects. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8578,7 +10282,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8586,7 +10290,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} rows - Array of rows data as JSON objects. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8595,7 +10299,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; createRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8603,16 +10307,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8624,14 +10328,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8670,7 +10374,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8680,7 +10413,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8688,7 +10421,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8697,7 +10430,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8706,7 +10439,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; upsertRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8714,16 +10447,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8735,14 +10468,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8781,7 +10514,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8791,7 +10553,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column 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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8800,7 +10562,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8809,7 +10571,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column 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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8819,7 +10581,7 @@ export class TablesDB { tableId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; updateRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8828,17 +10590,17 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8851,7 +10613,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -8859,7 +10621,7 @@ export class TablesDB { 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 | null, }; } @@ -8899,7 +10661,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10796,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10943,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9133,8 +10971,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9145,8 +10983,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -9155,8 +10993,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9168,8 +11006,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; upsertRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9181,8 +11019,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9191,8 +11029,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9202,8 +11040,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9219,8 +11057,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9231,8 +11069,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9277,7 +11115,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9287,8 +11143,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9299,8 +11155,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -9309,8 +11165,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9322,8 +11178,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; updateRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9335,8 +11191,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9345,8 +11201,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9356,8 +11212,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9373,8 +11229,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9385,8 +11241,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9431,7 +11287,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9549,8 +11423,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9560,8 +11434,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Decrement a specific column of a row by a given value. @@ -9571,8 +11445,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9583,8 +11457,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Row>; decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9594,11 +11468,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9606,8 +11487,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -9621,8 +11502,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9631,8 +11512,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9683,7 +11564,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9694,8 +11593,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9705,8 +11604,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Increment a specific column of a row by a given value. @@ -9716,8 +11615,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9728,8 +11627,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Row>; incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9739,11 +11638,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9751,8 +11657,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -9766,8 +11672,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9776,8 +11682,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9828,6 +11734,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..8e9f2ae 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,34 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + teams: [], + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +205,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +278,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +368,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +517,38 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +638,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +732,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,21 +760,21 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} teamId - Team ID. * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. @@ -631,22 +782,22 @@ export class Teams { updateInstallation( teamId: string, installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: | { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.AppInstallation> { let params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; if ( @@ -657,13 +808,13 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string, + authorizationDetails: rest[1] as string | null, }; } @@ -696,7 +847,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1041,44 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -890,6 +1098,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} */ @@ -901,6 +1110,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise<Models.Membership>; /** * 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. @@ -919,6 +1129,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} * @deprecated Use the object parameter style method for a better developer experience. @@ -931,6 +1142,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise<Models.Membership>; createMembership( paramsOrFirst: @@ -942,9 +1154,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise<Models.Membership> { let params: { teamId: string; @@ -954,6 +1175,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -969,6 +1191,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -979,6 +1202,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -989,6 +1213,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1018,6 +1243,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1026,7 +1254,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1354,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1471,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1688,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..580a3d4 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,36 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -116,21 +150,21 @@ export class Tokens { * * @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 unique ID. - * @param {string} params.expire - Token expiry date + * @param {string | null} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ createFileToken(params: { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * * @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 unique ID. - * @param {string} expire - Token expiry date + * @param {string | null} expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. @@ -138,14 +172,19 @@ export class Tokens { createFileToken( bucketId: string, fileId: string, - expire?: string, + expire?: string | null, ): Promise<Models.ResourceToken>; createFileToken( paramsOrFirst: - { bucketId: string; fileId: string; expire?: string } | string, - ...rest: [string?, string?] + | { bucketId: string; fileId: string; expire?: string | null } + | string, + ...rest: [string?, (string | null)?] ): Promise<Models.ResourceToken> { - let params: { bucketId: string; fileId: string; expire?: string }; + let params: { + bucketId: string; + fileId: string; + expire?: string | null; + }; if ( paramsOrFirst && @@ -155,13 +194,13 @@ export class Tokens { params = (paramsOrFirst || {}) as { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string, + expire: rest[1] as string | null, }; } @@ -191,7 +230,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,36 +303,57 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} params.tokenId - Token unique ID. - * @param {string} params.expire - File token expiry date + * @param {string | null} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ update(params: { tokenId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} tokenId - Token unique ID. - * @param {string} expire - File token expiry date + * @param {string | null} expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; update( - paramsOrFirst: { tokenId: string; expire?: string } | string, - ...rest: [string?] + tokenId: string, + expire?: string | null, + ): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string; expire?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.ResourceToken> { - let params: { tokenId: string; expire?: string }; + let params: { tokenId: string; expire?: string | null }; if ( paramsOrFirst && @@ -284,12 +362,12 @@ export class Tokens { ) { params = (paramsOrFirst || {}) as { tokenId: string; - expire?: string; + expire?: string | null; }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string, + expire: rest[0] as string | null, }; } @@ -316,7 +394,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..77a515b 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,16 +94,70 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + users: [], + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new user. * * @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. - * @param {string} params.email - User email. - * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string | null} params.email - User email. + * @param {string | null} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} params.password - Plain text user password. Must be at least 8 chars. * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -107,18 +166,18 @@ export class Users { Preferences extends Models.Preferences = Models.DefaultPreferences, >(params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }): Promise<Models.User<Preferences>>; /** * Create a new user. * * @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. - * @param {string} email - User email. - * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string | null} email - User email. + * @param {string | null} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} password - Plain text user password. Must be at least 8 chars. * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -126,28 +185,28 @@ export class Users { */ create<Preferences extends Models.Preferences = Models.DefaultPreferences>( userId: string, - email?: string, - phone?: string, - password?: string, + email?: string | null, + phone?: string | null, + password?: string | null, name?: string, ): Promise<Models.User<Preferences>>; create<Preferences extends Models.Preferences = Models.DefaultPreferences>( paramsOrFirst: | { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [(string | null)?, (string | null)?, (string | null)?, string?] ): Promise<Models.User<Preferences>> { let params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; @@ -158,17 +217,17 @@ export class Users { ) { params = (paramsOrFirst || {}) as { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string, - phone: rest[1] as string, - password: rest[2] as string, + email: rest[0] as string | null, + phone: rest[1] as string | null, + password: rest[2] as string | null, name: rest[3] as string, }; } @@ -206,7 +265,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +420,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +575,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +697,40 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +898,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1053,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1307,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1518,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1690,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1790,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1959,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2083,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2301,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2446,44 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2558,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2675,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2930,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +3000,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3069,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3141,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3277,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3345,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3414,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3482,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3568,410 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise<Models.PasskeyList> { + 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, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise<Models.Passkey>; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4050,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4170,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4408,58 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4517,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4752,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4876,37 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5048,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5135,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5270,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5439,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5538,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5663,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..d2f0c5d 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,69 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class VectorsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class VectorsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class VectorsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,59 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1530,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1647,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1209,7 +1700,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} */ @@ -1220,7 +1711,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.VectorsdbCollection>; /** * Update a collection by its unique ID. @@ -1231,7 +1722,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1243,7 +1734,7 @@ export class VectorsDB { dimension?: number, permissions?: string[], documentSecurity?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.VectorsdbCollection>; updateCollection( paramsOrFirst: @@ -1254,10 +1745,17 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ...rest: [ + string?, + string?, + number?, + string[]?, + boolean?, + (boolean | null)?, + ] ): Promise<Models.VectorsdbCollection> { let params: { databaseId: string; @@ -1266,7 +1764,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -1281,7 +1779,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -1291,7 +1789,7 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean, + enabled: rest[5] as boolean | null, }; } @@ -1345,7 +1843,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2093,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2291,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2426,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2574,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2727,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2868,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +3035,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3193,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3380,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3567,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3810,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +4006,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4114,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3377,33 +4230,33 @@ export class VectorsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3412,12 +4265,12 @@ export class VectorsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3444,7 +4297,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4457,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4544,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4628,51 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..f5ecff3 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2415 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise<Models.WafRuleList>; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise<Models.WafRuleList>; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise<Models.WafRuleList> { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + rules: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleBypass>; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleBypass>; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleBypass>; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleBypass>; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise<Models.WafRuleChallenge>; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise<Models.WafRuleChallenge>; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.challengeType - Challenge type enforced by the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }): Promise<Models.WafRuleChallenge>; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} challengeType - Challenge type enforced by the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + challengeType?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + difficulty?: number | null, + ttl?: number | null, + ): Promise<Models.WafRuleChallenge>; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + challengeType: rest[4] as string | null, + priority: rest[5] as number | null, + enabled: rest[6] as boolean | null, + conditions: rest[7] as string[] | null, + difficulty: rest[8] as number | null, + ttl: rest[9] as number | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleDeny>; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleDeny>; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleDeny>; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleDeny>; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRateLimit>; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string | null, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number | null, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRateLimit>; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + (string | null)?, + string?, + string?, + string?, + (number | null)?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number | null, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRateLimit>; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} interval - Interval in seconds used for rate limiting. + * @param {string | null} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + limit?: number | null, + interval?: number | null, + key?: string | null, + maxBucketSize?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRateLimit>; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + limit: rest[4] as number | null, + interval: rest[5] as number | null, + key: rest[6] as string | null, + maxBucketSize: rest[7] as number | null, + priority: rest[8] as number | null, + enabled: rest[9] as boolean | null, + conditions: rest[10] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRedirect>; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRedirect>; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.location - Location used for redirect responses. + * @param {number | null} params.statusCode - Integer status code used for redirect responses. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRedirect>; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} location - Location used for redirect responses. + * @param {number | null} statusCode - Integer status code used for redirect responses. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + location?: string | null, + statusCode?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRedirect>; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + location: rest[4] as string | null, + statusCode: rest[5] as number | null, + priority: rest[6] as number | null, + enabled: rest[7] as boolean | null, + conditions: rest[8] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..32f492f 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,42 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + webhooks: [], + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,9 +122,9 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -97,7 +137,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -108,9 +148,9 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -124,7 +164,7 @@ export class Webhooks { tls?: boolean, authUsername?: string, authPassword?: string, - secret?: string, + secret?: string | null, ): Promise<Models.Webhook>; create( paramsOrFirst: @@ -137,7 +177,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; } | string, ...rest: [ @@ -148,7 +188,7 @@ export class Webhooks { boolean?, string?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -160,7 +200,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; if ( @@ -177,7 +217,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; } else { params = { @@ -189,7 +229,7 @@ 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 | null, }; } @@ -253,7 +293,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +372,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +408,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -333,7 +421,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }): Promise<Models.Webhook>; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -344,8 +432,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -358,7 +446,7 @@ export class Webhooks { enabled?: boolean, tls?: boolean, authUsername?: string, - authPassword?: string, + authPassword?: string | null, ): Promise<Models.Webhook>; update( paramsOrFirst: @@ -370,7 +458,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; } | string, ...rest: [ @@ -380,7 +468,7 @@ export class Webhooks { boolean?, boolean?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -391,7 +479,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; if ( @@ -407,7 +495,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; } else { params = { @@ -418,7 +506,7 @@ 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 | null, }; } @@ -478,7 +566,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -539,29 +651,32 @@ export class Webhooks { * 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. * * @param {string} params.webhookId - Webhook ID. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ updateSecret(params: { webhookId: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * 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. * * @param {string} webhookId - Webhook ID. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; updateSecret( - paramsOrFirst: { webhookId: string; secret?: string } | string, - ...rest: [string?] + webhookId: string, + secret?: string | null, + ): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string; secret?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.Webhook> { - let params: { webhookId: string; secret?: string }; + let params: { webhookId: string; secret?: string | null }; if ( paramsOrFirst && @@ -570,12 +685,12 @@ export class Webhooks { ) { params = (paramsOrFirst || {}) as { webhookId: string; - secret?: string; + secret?: string | null; }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string, + secret: rest[0] as string | null, }; } @@ -602,6 +717,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/topic.ts b/src/topic.ts deleted file mode 100644 index cd6cea0..0000000 --- a/src/topic.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding - * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). - */ -function levelsOf(levels: unknown): string[] { - if (!Array.isArray(levels)) { - throw new Error("path() expects an array, e.g. path(['user'])"); - } - if (levels.length === 0) { - throw new Error('path() needs at least one level'); - } - return levels.map((level: unknown, index: number) => { - if (typeof level !== 'string') { - const type = level === null ? 'null' : typeof level; - throw new Error( - `level at index ${index} must be a string, got ${type}`, - ); - } - if (level === '') { - throw new Error(`empty level at index ${index}`); - } - if (level.includes('/')) { - const parts = level - .split('/') - .map((part) => `'${part}'`) - .join(', '); - throw new Error( - `"${level}" contains "/", split it: path([${parts}])`, - ); - } - if (level === '+') { - throw new Error('"+" is reserved, use any()'); - } - if (level.includes('+')) { - throw new Error(`"${level}" contains "+", use any() for wildcards`); - } - if (level === '#') { - throw new Error('"#" is reserved, use all()'); - } - if (level.includes('#')) { - throw new Error(`"${level}" contains "#", use all() for wildcards`); - } - return level; - }); -} - -/** - * Helper to build MQTT topics for `Push`, level by level. - * - * Topic.path(['user', userId, 'notification']); // "user/123/notification" - * Topic.path(['user']).any().path(['notification']); // "user/+/notification" - * Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#" - * - * `any()` matches exactly one level and `all()` everything below, at any depth (including the - * parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}. - */ -export class Topic { - private constructor(private readonly levels: readonly string[]) {} - - /** Start a topic with the given levels, e.g. `Topic.path(['user', userId])`. */ - static path(levels: string[]): Topic { - return new Topic(levelsOf(levels)); - } - - /** Start a topic with a single-level wildcard (`+`). */ - static any(): Topic { - return new Topic(['+']); - } - - /** The multi-level wildcard alone (`#`): matches every topic. */ - static all(): ResolvedTopic { - return new ResolvedTopic(['#']); - } - - /** Append the given levels. */ - path(levels: string[]): Topic { - return new Topic([...this.levels, ...levelsOf(levels)]); - } - - /** Append a single-level wildcard (`+`): matches exactly one level. */ - any(): Topic { - return new Topic([...this.levels, '+']); - } - - /** Append the multi-level wildcard (`#`) and end the topic. */ - all(): ResolvedTopic { - return new ResolvedTopic([...this.levels, '#']); - } - - toString(): string { - return this.levels.join('/'); - } -} - -/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */ -export class ResolvedTopic { - /** @internal Created by {@link Topic.all}. */ - constructor(private readonly levels: readonly string[]) {} - - toString(): string { - return this.levels.join('/'); - } -} diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..0bd3f1c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -13,9 +13,9 @@ describe('Account', () => { 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', + $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, @@ -40,9 +40,9 @@ describe('Account', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Account', () => { }); 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', + $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', @@ -129,9 +129,9 @@ describe('Account', () => { }); 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', + $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', @@ -168,9 +168,9 @@ describe('Account', () => { }); 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', + $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, @@ -221,9 +221,9 @@ describe('Account', () => { }); 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', + $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, @@ -274,9 +274,9 @@ describe('Account', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Account', () => { }); 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', + $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, @@ -348,8 +348,8 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -363,8 +363,8 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -378,9 +378,9 @@ describe('Account', () => { }); 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', + $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', @@ -421,9 +421,9 @@ describe('Account', () => { }); 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', + $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', @@ -568,9 +568,9 @@ describe('Account', () => { }); 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', + $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, @@ -593,11 +593,101 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('<PASSKEY_ID>', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '<PASSKEY_ID>', + {}, + ); + + // 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', + $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, @@ -622,9 +712,9 @@ describe('Account', () => { }); 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', + $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, @@ -659,9 +749,9 @@ describe('Account', () => { }); 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', + $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, @@ -686,8 +776,8 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -706,8 +796,8 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -727,8 +817,8 @@ describe('Account', () => { }); test('test method createRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -744,8 +834,8 @@ describe('Account', () => { }); test('test method updateRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -788,9 +878,9 @@ describe('Account', () => { }); 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', + $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', @@ -828,9 +918,9 @@ describe('Account', () => { }); 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', + $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', @@ -871,9 +961,9 @@ describe('Account', () => { }); test('test method createIdTokenSession()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -914,9 +1004,9 @@ describe('Account', () => { }); 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', + $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', @@ -957,9 +1047,9 @@ describe('Account', () => { }); 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', + $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', @@ -1000,9 +1090,9 @@ describe('Account', () => { }); 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', + $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', @@ -1040,9 +1130,9 @@ describe('Account', () => { }); 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', + $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', @@ -1080,9 +1170,9 @@ describe('Account', () => { }); 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', + $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', @@ -1130,9 +1220,9 @@ describe('Account', () => { }); 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', + $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, @@ -1157,8 +1247,8 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1177,8 +1267,8 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1205,10 +1295,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('<CHALLENGE_ID>', {}); + + // 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', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1227,8 +1350,8 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1246,8 +1369,8 @@ describe('Account', () => { }); test('test method createVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1265,8 +1388,8 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1285,8 +1408,8 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1305,8 +1428,8 @@ describe('Account', () => { }); test('test method createEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1322,8 +1445,8 @@ describe('Account', () => { }); test('test method updateEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1342,8 +1465,8 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1359,8 +1482,8 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 5270074..4c59cab 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', actorType: 'user', actorId: '610fc2f985ee0', actorEmail: 'john@appwrite.io', diff --git a/test/services/advisor.test.js b/test/services/advisor.test.js index 777728a..b3ff64d 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -26,9 +26,9 @@ describe('Advisor', () => { }); 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', + $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/', @@ -71,9 +71,9 @@ describe('Advisor', () => { }); 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', + $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', diff --git a/test/services/apps.test.js b/test/services/apps.test.js index d79c42c..a63e37e 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -26,9 +26,9 @@ describe('Apps', () => { }); 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', + $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', @@ -89,9 +89,9 @@ describe('Apps', () => { }); 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', + $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', @@ -126,9 +126,9 @@ describe('Apps', () => { }); 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', + $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', @@ -186,9 +186,9 @@ describe('Apps', () => { }); 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', + $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: [], @@ -254,9 +254,9 @@ describe('Apps', () => { }); 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', + $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', @@ -273,9 +273,9 @@ describe('Apps', () => { }); 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', + $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', @@ -302,9 +302,9 @@ describe('Apps', () => { }); 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', + $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', @@ -352,9 +352,9 @@ describe('Apps', () => { }); 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', + $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', @@ -371,9 +371,9 @@ describe('Apps', () => { }); 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', + $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', @@ -400,9 +400,9 @@ describe('Apps', () => { }); 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', + $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', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index c65b1b9..ecd4504 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -84,9 +84,9 @@ describe('Avatars', () => { }); test('test method updatePhoto()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 922f68d..e1db580 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -26,9 +26,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -45,9 +45,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -87,10 +87,10 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -113,10 +113,10 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -134,10 +134,10 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -165,9 +165,9 @@ describe('Backups', () => { }); 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', + $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', @@ -199,9 +199,9 @@ describe('Backups', () => { }); 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', + $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', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2af87b0..502bcb0 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -26,10 +26,10 @@ describe('Databases', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -56,9 +56,9 @@ describe('Databases', () => { }); 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', + $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', @@ -73,9 +73,9 @@ describe('Databases', () => { }); 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', + $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', @@ -90,9 +90,9 @@ describe('Databases', () => { }); 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', + $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', @@ -117,9 +117,9 @@ describe('Databases', () => { }); 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', + $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', @@ -134,10 +134,10 @@ describe('Databases', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -151,10 +151,10 @@ describe('Databases', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,10 +191,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -218,10 +218,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -244,10 +244,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -304,8 +304,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -327,8 +327,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -351,8 +351,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -374,8 +374,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -398,8 +398,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -422,8 +422,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -447,8 +447,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -471,8 +471,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -496,8 +496,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -522,8 +522,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -549,8 +549,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -572,8 +572,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -596,8 +596,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -619,8 +619,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -643,8 +643,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -667,8 +667,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -692,8 +692,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -715,8 +715,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -738,8 +738,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -761,8 +761,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -785,8 +785,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -808,8 +808,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -832,8 +832,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -855,8 +855,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -878,8 +878,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -901,8 +901,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -924,8 +924,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -953,8 +953,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -981,8 +981,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1006,8 +1006,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1031,8 +1031,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1054,8 +1054,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1078,8 +1078,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1102,8 +1102,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1127,8 +1127,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1152,8 +1152,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1177,8 +1177,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1225,13 +1225,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1314,13 +1314,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1336,13 +1336,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1358,13 +1358,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1394,13 +1394,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1417,13 +1417,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1456,9 +1456,9 @@ describe('Databases', () => { }); 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', + $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', @@ -1482,9 +1482,9 @@ describe('Databases', () => { }); 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', + $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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..b56872d 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -26,10 +26,10 @@ describe('DocumentsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -132,9 +132,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -149,10 +149,10 @@ describe('DocumentsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -166,10 +166,10 @@ describe('DocumentsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -206,10 +206,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -259,10 +259,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -315,13 +315,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -404,13 +404,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -426,13 +426,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -448,13 +448,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -484,13 +484,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -507,13 +507,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -546,9 +546,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -572,9 +572,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -610,21 +610,17 @@ describe('DocumentsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/domains.test.js b/test/services/domains.test.js index fc86018..f77cb0e 100644 --- a/test/services/domains.test.js +++ b/test/services/domains.test.js @@ -26,9 +26,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -79,9 +79,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -112,9 +112,9 @@ describe('Domains', () => { }); test('test method updateNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -135,9 +135,9 @@ describe('Domains', () => { }); test('test method verifyNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -328,9 +328,9 @@ describe('Domains', () => { }); test('test method createRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -356,9 +356,9 @@ describe('Domains', () => { }); test('test method updateRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -385,9 +385,9 @@ describe('Domains', () => { }); test('test method createRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -413,9 +413,9 @@ describe('Domains', () => { }); test('test method updateRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -442,9 +442,9 @@ describe('Domains', () => { }); test('test method createRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -470,9 +470,9 @@ describe('Domains', () => { }); test('test method updateRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -499,9 +499,9 @@ describe('Domains', () => { }); test('test method createRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -527,9 +527,9 @@ describe('Domains', () => { }); test('test method updateRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -556,9 +556,9 @@ describe('Domains', () => { }); test('test method createRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -584,9 +584,9 @@ describe('Domains', () => { }); test('test method updateRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -613,9 +613,9 @@ describe('Domains', () => { }); test('test method createRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -641,9 +641,9 @@ describe('Domains', () => { }); test('test method updateRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -670,9 +670,9 @@ describe('Domains', () => { }); test('test method createRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -699,9 +699,9 @@ describe('Domains', () => { }); test('test method updateRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -729,9 +729,9 @@ describe('Domains', () => { }); test('test method createRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -757,9 +757,9 @@ describe('Domains', () => { }); test('test method updateRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -786,9 +786,9 @@ describe('Domains', () => { }); test('test method createRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -817,9 +817,9 @@ describe('Domains', () => { }); test('test method updateRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -849,9 +849,9 @@ describe('Domains', () => { }); test('test method createRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -876,9 +876,9 @@ describe('Domains', () => { }); test('test method updateRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -905,9 +905,9 @@ describe('Domains', () => { }); test('test method getRecord()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -941,9 +941,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -988,9 +988,9 @@ describe('Domains', () => { }); test('test method updateZone()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', diff --git a/test/services/functions.test.js b/test/services/functions.test.js index fba574b..b40183d 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -27,9 +27,9 @@ describe('Functions', () => { }); 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', + $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, @@ -100,9 +100,9 @@ describe('Functions', () => { }); 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', + $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, @@ -143,9 +143,9 @@ describe('Functions', () => { }); 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', + $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, @@ -196,9 +196,9 @@ describe('Functions', () => { }); 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', + $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, @@ -255,9 +255,9 @@ describe('Functions', () => { }); 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', + $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', @@ -300,9 +300,9 @@ describe('Functions', () => { }); 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', + $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', @@ -344,9 +344,9 @@ describe('Functions', () => { }); 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', + $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', @@ -392,9 +392,9 @@ describe('Functions', () => { }); 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', + $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', @@ -437,9 +437,9 @@ describe('Functions', () => { }); 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', + $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', @@ -507,9 +507,9 @@ describe('Functions', () => { }); 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', + $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', @@ -564,10 +564,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -593,10 +593,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -651,9 +651,9 @@ describe('Functions', () => { }); 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', + $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, @@ -675,9 +675,9 @@ describe('Functions', () => { }); 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', + $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, @@ -697,9 +697,9 @@ describe('Functions', () => { }); 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', + $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, diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 25df258..3ffc4e3 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -26,9 +26,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -51,9 +51,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -72,9 +72,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -93,9 +93,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -114,9 +114,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -135,9 +135,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -156,9 +156,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -177,9 +177,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -198,9 +198,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -255,9 +255,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -277,9 +277,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -299,9 +299,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -318,9 +318,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -337,9 +337,9 @@ describe('Messaging', () => { }); test('test method createAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -359,9 +359,9 @@ describe('Messaging', () => { }); test('test method updateAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -379,9 +379,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -401,9 +401,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -423,9 +423,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -442,9 +442,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -461,9 +461,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -483,9 +483,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -502,9 +502,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -524,9 +524,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -543,9 +543,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -565,9 +565,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -584,9 +584,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -606,9 +606,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -626,9 +626,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -648,9 +648,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -667,9 +667,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -690,9 +690,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -713,9 +713,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -732,9 +732,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -751,9 +751,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -773,9 +773,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -793,9 +793,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -815,9 +815,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -835,9 +835,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -857,9 +857,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -876,9 +876,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -898,9 +898,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -917,9 +917,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -959,9 +959,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -978,9 +978,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -997,9 +997,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -1039,9 +1039,9 @@ describe('Messaging', () => { }); 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', + $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', @@ -1063,9 +1063,9 @@ describe('Messaging', () => { }); 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', + $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', diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..1df9e5f 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -26,21 +26,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mongo', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mongo', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mongo', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mongo', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mongo', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mongo', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -586,21 +566,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -647,21 +623,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -712,21 +684,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -829,17 +797,12 @@ describe('Mongo', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -852,17 +815,12 @@ describe('Mongo', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -900,21 +858,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..f9a83f3 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -26,21 +26,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mysql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mysql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mysql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mysql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mysql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mysql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -603,21 +583,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -664,21 +640,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -729,21 +701,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -888,17 +856,12 @@ describe('Mysql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -911,17 +874,12 @@ describe('Mysql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -959,21 +917,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 476045a..79d73e5 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -70,9 +70,9 @@ describe('Oauth2', () => { }); 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', + $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: [], @@ -94,9 +94,9 @@ describe('Oauth2', () => { }); 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', + $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: [], diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..e955287 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -13,9 +13,9 @@ describe('Organization', () => { 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', + $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: {}, @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -46,9 +39,9 @@ describe('Organization', () => { }); 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', + $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: {}, @@ -57,13 +50,6 @@ describe('Organization', () => { 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', @@ -102,9 +88,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -122,9 +108,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -143,9 +129,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -188,9 +174,9 @@ describe('Organization', () => { }); 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', + $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', @@ -214,9 +200,9 @@ describe('Organization', () => { }); 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', + $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', @@ -240,9 +226,9 @@ describe('Organization', () => { }); 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', + $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', @@ -292,9 +278,9 @@ describe('Organization', () => { }); 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', + $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', @@ -332,9 +318,9 @@ describe('Organization', () => { }); 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', + $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', @@ -369,9 +355,9 @@ describe('Organization', () => { }); 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', + $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', @@ -432,9 +418,9 @@ describe('Organization', () => { }); test('test method createEphemeralProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -456,9 +442,9 @@ describe('Organization', () => { }); test('test method getProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -479,9 +465,9 @@ describe('Organization', () => { }); test('test method updateProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..67244cf 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -26,21 +26,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Postgresql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Postgresql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Postgresql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Postgresql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Postgresql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -445,21 +433,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,21 +490,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -570,8 +550,8 @@ describe('Postgresql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -623,21 +603,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -687,21 +663,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -751,21 +723,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -812,21 +780,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -877,21 +841,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1039,17 +999,12 @@ describe('Postgresql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1062,17 +1017,12 @@ describe('Postgresql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1110,21 +1060,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/presences.test.js b/test/services/presences.test.js index b388216..ee08169 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -26,10 +26,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -43,10 +43,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -64,10 +64,10 @@ describe('Presences', () => { }); 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': [], + $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', }; diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..13066dc 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -13,9 +13,9 @@ describe('Project', () => { 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', + $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', @@ -60,9 +60,9 @@ describe('Project', () => { }); 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', + $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', @@ -95,6 +95,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment('<ENVIRONMENT_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment('<ENVIRONMENT_ID>'); + + // 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, @@ -110,9 +250,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -130,9 +270,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -150,9 +290,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -180,9 +320,9 @@ describe('Project', () => { }); 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', + $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', @@ -232,8 +372,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -247,8 +387,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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'); @@ -262,8 +402,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -298,9 +438,9 @@ describe('Project', () => { }); 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', + $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', @@ -338,7 +478,7 @@ describe('Project', () => { }); test('test method updateOAuth2Amazon()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', @@ -355,7 +495,7 @@ describe('Project', () => { }); test('test method updateOAuth2Apple()', async () => { const data = { - '\\$id': 'apple', + $id: 'apple', enabled: true, serviceId: 'ip.appwrite.app.web', keyId: 'P4000000N8', @@ -374,7 +514,7 @@ describe('Project', () => { }); test('test method updateOAuth2Appwrite()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a42000000000000b5a0', clientSecret: @@ -390,7 +530,7 @@ describe('Project', () => { }); test('test method updateOAuth2Auth0()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'OaOkIA000000000000000000005KLSYq', clientSecret: @@ -408,7 +548,7 @@ describe('Project', () => { }); test('test method updateOAuth2Authentik()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dTKOPa0000000000000000000000000000e7G8hv', clientSecret: @@ -425,7 +565,7 @@ describe('Project', () => { }); test('test method updateOAuth2Autodesk()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '5zw90v00000000000000000000kVYXN7', clientSecret: '7I000000000000MW', @@ -440,7 +580,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitbucket()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, key: 'Knt70000000000ByRc', secret: 'NMfLZJ00000000000000000000TLQdDx', @@ -455,7 +595,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitly()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'd95151000000000000000000000000000067af9b', clientSecret: 'a13e250000000000000000000000000000d73095', @@ -470,7 +610,7 @@ describe('Project', () => { }); test('test method updateOAuth2Box()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'deglcs00000000000000000000x2og6y', clientSecret: 'OKM1f100000000000000000000eshEif', @@ -485,7 +625,7 @@ describe('Project', () => { }); test('test method updateOAuth2Cloudflare()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '4b866000000000000000000000c9e4e2', clientSecret: @@ -501,7 +641,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dailymotion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, apiKey: '07a9000000000000067f', apiSecret: 'a399a90000000000000000000000000000d90639', @@ -516,7 +656,7 @@ describe('Project', () => { }); test('test method updateOAuth2Discord()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '950722000000343754', clientSecret: 'YmPXnM000000000000000000002zFg5D', @@ -532,7 +672,7 @@ describe('Project', () => { }); test('test method updateOAuth2Disqus()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, publicKey: 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', @@ -549,7 +689,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dropbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appKey: 'jl000000000009t', appSecret: 'g200000000000vw', @@ -564,7 +704,7 @@ describe('Project', () => { }); test('test method updateOAuth2Etsy()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, keyString: 'nsgzxh0000000000008j85a2', sharedSecret: 'tp000000ru', @@ -579,7 +719,7 @@ describe('Project', () => { }); test('test method updateOAuth2Facebook()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appId: '260600000007694', appSecret: '2d0b2800000000000000000000d38af4', @@ -594,7 +734,7 @@ describe('Project', () => { }); test('test method updateOAuth2Figma()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'byay5H0000000000VtiI40', clientSecret: 'yEpOYn0000000000000000004iIsU5', @@ -609,7 +749,7 @@ describe('Project', () => { }); test('test method updateOAuth2FusionAuth()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'b2222c00-0000-0000-0000-000000862097', clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', @@ -625,7 +765,7 @@ describe('Project', () => { }); test('test method updateOAuth2GitHub()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'e4d87900000000540733', clientSecret: '5e07c00000000000000000000000000000198bcc', @@ -641,7 +781,7 @@ describe('Project', () => { }); test('test method updateOAuth2Gitlab()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', @@ -658,7 +798,7 @@ describe('Project', () => { }); test('test method updateOAuth2Google()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', @@ -677,7 +817,7 @@ describe('Project', () => { }); test('test method updateOAuth2HuggingFace()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', @@ -692,7 +832,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kakao()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -708,7 +848,7 @@ describe('Project', () => { }); test('test method updateOAuth2Keycloak()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-o0000000st-app', clientSecret: 'jdjrJd00000000000000000000HUsaZO', @@ -725,7 +865,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kick()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '01KQ7C00000000000001MFHS32', clientSecret: @@ -741,7 +881,7 @@ describe('Project', () => { }); test('test method updateOAuth2Linkedin()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '770000000000dv', primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', @@ -756,7 +896,7 @@ describe('Project', () => { }); test('test method updateOAuth2Microsoft()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', @@ -773,7 +913,7 @@ describe('Project', () => { }); test('test method updateOAuth2Notion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauthClientId: '341d8700-0000-0000-0000-000000446ee3', oauthClientSecret: @@ -789,7 +929,7 @@ describe('Project', () => { }); test('test method updateOAuth2Oidc()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'qibI2x0000000000000000000000000006L2YFoG', clientSecret: @@ -811,7 +951,7 @@ describe('Project', () => { }); test('test method updateOAuth2Okta()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '0oa00000000000000698', clientSecret: @@ -830,7 +970,7 @@ describe('Project', () => { }); test('test method updateOAuth2Paypal()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -847,7 +987,7 @@ describe('Project', () => { }); test('test method updateOAuth2PaypalSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -864,7 +1004,7 @@ describe('Project', () => { }); test('test method updateOAuth2Podio()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-oauth-test-app', clientSecret: @@ -880,7 +1020,7 @@ describe('Project', () => { }); test('test method updateOAuth2Resend()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', clientSecret: @@ -896,7 +1036,7 @@ describe('Project', () => { }); test('test method updateOAuth2Salesforce()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', @@ -913,7 +1053,7 @@ describe('Project', () => { }); test('test method updateOAuth2Slack()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '23000000089.15000000000023', clientSecret: '81656000000000000000000000f3d2fd', @@ -928,7 +1068,7 @@ describe('Project', () => { }); test('test method updateOAuth2Spotify()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6ec271000000000000000000009beace', clientSecret: 'db068a000000000000000000008b5b9f', @@ -943,7 +1083,7 @@ describe('Project', () => { }); test('test method updateOAuth2Stripe()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'ca_UKibXX0000000000000000000006byvR', apiSecretKey: @@ -959,7 +1099,7 @@ describe('Project', () => { }); test('test method updateOAuth2TikTok()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'awz000000000tyw0', clientSecret: '6wXewM00000000000000000000yXnite', @@ -974,7 +1114,7 @@ describe('Project', () => { }); test('test method updateOAuth2Tradeshift()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -989,7 +1129,7 @@ describe('Project', () => { }); test('test method updateOAuth2TradeshiftSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -1004,7 +1144,7 @@ describe('Project', () => { }); test('test method updateOAuth2Twitch()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'vvi0in000000000000000000ikmt9p', clientSecret: 'pmapue000000000000000000zylw3v', @@ -1019,7 +1159,7 @@ describe('Project', () => { }); test('test method updateOAuth2Webflow()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '8bb20000000000000000000000000000000000000000000000000000000040dd', @@ -1036,7 +1176,7 @@ describe('Project', () => { }); test('test method updateOAuth2WordPress()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '130005', clientSecret: @@ -1052,7 +1192,7 @@ describe('Project', () => { }); test('test method updateOAuth2X()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: 'slzZV0000000000000NFLaWT', secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', @@ -1067,7 +1207,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yahoo()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', @@ -1083,7 +1223,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yandex()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a8a6a0000000000000000000091483c', clientSecret: 'bbf98500000000000000000000c75a63', @@ -1098,7 +1238,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoho()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '1000.83C178000000000000000000RPNX0B', clientSecret: 'fb5cac000000000000000000000000000000a68f6e', @@ -1114,7 +1254,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoom()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'QMAC00000000000000w0AQ', clientSecret: 'GAWsG4000000000000000000007U01ON', @@ -1129,7 +1269,7 @@ describe('Project', () => { }); test('test method getOAuth2Provider()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -1158,12 +1298,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1179,12 +1320,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1200,9 +1342,9 @@ describe('Project', () => { }); 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', + $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', @@ -1221,9 +1363,9 @@ describe('Project', () => { }); 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', + $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', @@ -1242,9 +1384,9 @@ describe('Project', () => { }); 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', + $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', @@ -1263,9 +1405,9 @@ describe('Project', () => { }); 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', + $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', @@ -1284,9 +1426,9 @@ describe('Project', () => { }); 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', + $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', @@ -1305,9 +1447,9 @@ describe('Project', () => { }); 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', + $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', @@ -1326,9 +1468,9 @@ describe('Project', () => { }); 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', + $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', @@ -1347,9 +1489,9 @@ describe('Project', () => { }); 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', + $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', @@ -1368,9 +1510,9 @@ describe('Project', () => { }); 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', + $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', @@ -1408,9 +1550,9 @@ describe('Project', () => { }); 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', + $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', @@ -1445,9 +1587,9 @@ describe('Project', () => { }); 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', + $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', @@ -1482,9 +1624,9 @@ describe('Project', () => { }); 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', + $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', @@ -1519,9 +1661,9 @@ describe('Project', () => { }); 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', + $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', @@ -1556,9 +1698,9 @@ describe('Project', () => { }); 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', + $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', @@ -1593,9 +1735,9 @@ describe('Project', () => { }); 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', + $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', @@ -1628,11 +1770,48 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy('<RP_ID>'); + + // 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', + $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', @@ -1667,9 +1846,9 @@ describe('Project', () => { }); 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', + $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', @@ -1704,9 +1883,9 @@ describe('Project', () => { }); 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', + $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', @@ -1741,9 +1920,9 @@ describe('Project', () => { }); test('test method updatePasswordPwnedPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -1776,9 +1955,46 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', + $id: 'password-dictionary', min: 12, uppercase: true, lowercase: true, @@ -1795,9 +2011,9 @@ describe('Project', () => { }); 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', + $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', @@ -1832,9 +2048,9 @@ describe('Project', () => { }); 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', + $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', @@ -1869,9 +2085,9 @@ describe('Project', () => { }); 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', + $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', @@ -1906,9 +2122,9 @@ describe('Project', () => { }); 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', + $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', @@ -1943,9 +2159,9 @@ describe('Project', () => { }); 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', + $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', @@ -1980,8 +2196,9 @@ describe('Project', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', - enabled: true, + $id: 'password-dictionary', + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); @@ -1993,9 +2210,9 @@ describe('Project', () => { }); 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', + $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', @@ -2030,9 +2247,9 @@ describe('Project', () => { }); 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', + $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', @@ -2067,9 +2284,9 @@ describe('Project', () => { }); 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', + $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', @@ -2178,9 +2395,9 @@ describe('Project', () => { }); 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', + $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, @@ -2201,9 +2418,9 @@ describe('Project', () => { }); 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', + $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, @@ -2220,9 +2437,9 @@ describe('Project', () => { }); 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', + $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, diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js index bf9d288..08576c6 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -41,9 +41,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -66,9 +66,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -94,9 +94,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -125,9 +125,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -150,9 +150,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -185,9 +185,9 @@ describe('Proxy', () => { }); 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', + $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', diff --git a/test/services/sites.test.js b/test/services/sites.test.js index 8e558d9..cf30e82 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -27,9 +27,9 @@ describe('Sites', () => { }); 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', + $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, @@ -104,9 +104,9 @@ describe('Sites', () => { }); 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', + $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, @@ -150,9 +150,9 @@ describe('Sites', () => { }); 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', + $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, @@ -206,9 +206,9 @@ describe('Sites', () => { }); 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', + $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, @@ -268,9 +268,9 @@ describe('Sites', () => { }); 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', + $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', @@ -312,9 +312,9 @@ describe('Sites', () => { }); 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', + $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', @@ -356,9 +356,9 @@ describe('Sites', () => { }); 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', + $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', @@ -404,9 +404,9 @@ describe('Sites', () => { }); 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', + $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', @@ -449,9 +449,9 @@ describe('Sites', () => { }); 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', + $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', @@ -519,9 +519,9 @@ describe('Sites', () => { }); 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', + $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', @@ -576,10 +576,10 @@ describe('Sites', () => { }); 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': [], + $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', @@ -628,9 +628,9 @@ describe('Sites', () => { }); 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', + $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, @@ -652,9 +652,9 @@ describe('Sites', () => { }); 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', + $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, @@ -671,9 +671,9 @@ describe('Sites', () => { }); 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', + $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, diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 7f35319..b46b168 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -27,10 +27,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -52,10 +52,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -77,10 +77,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -125,11 +125,11 @@ describe('Storage', () => { }); test('test method createFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -156,11 +156,11 @@ describe('Storage', () => { }); test('test method getFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -183,11 +183,11 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..6320233 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -26,10 +26,10 @@ describe('TablesDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('TablesDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('TablesDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,21 +191,17 @@ describe('TablesDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -265,9 +261,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -296,9 +292,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -340,9 +336,9 @@ describe('TablesDB', () => { }); test('test method createCutover()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -436,10 +432,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -463,10 +459,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -486,10 +482,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -546,8 +542,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -569,8 +565,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -593,8 +589,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -616,8 +612,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -640,8 +636,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -664,8 +660,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -689,8 +685,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -713,8 +709,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -738,8 +734,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -764,8 +760,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -791,8 +787,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -814,8 +810,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -838,8 +834,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -861,8 +857,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -885,8 +881,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -909,8 +905,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -934,8 +930,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -957,8 +953,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -980,8 +976,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1003,8 +999,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1027,8 +1023,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1050,8 +1046,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1074,8 +1070,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1097,8 +1093,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1120,8 +1116,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1143,8 +1139,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1166,8 +1162,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1195,8 +1191,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1223,8 +1219,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1248,8 +1244,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1273,8 +1269,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1296,8 +1292,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1320,8 +1316,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1344,8 +1340,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1369,8 +1365,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1394,8 +1390,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1419,8 +1415,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1467,9 +1463,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1493,9 +1489,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1544,13 +1540,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1633,13 +1629,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1655,13 +1651,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1677,13 +1673,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1713,13 +1709,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1736,13 +1732,13 @@ describe('TablesDB', () => { }); 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': [], + $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( diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 7dcf744..0248491 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -26,9 +26,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -43,9 +43,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -60,9 +60,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -100,9 +100,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -123,9 +123,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -146,9 +146,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -195,9 +195,9 @@ describe('Teams', () => { }); 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', + $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', @@ -221,9 +221,9 @@ describe('Teams', () => { }); 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', + $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', @@ -250,9 +250,9 @@ describe('Teams', () => { }); 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', + $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', @@ -293,9 +293,9 @@ describe('Teams', () => { }); 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', + $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', diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index 323ab93..1850b2e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -26,8 +26,8 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -47,8 +47,8 @@ describe('Tokens', () => { }); test('test method get()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -65,8 +65,8 @@ describe('Tokens', () => { }); test('test method update()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..21befd9 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -26,9 +26,9 @@ describe('Users', () => { }); 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', + $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, @@ -53,9 +53,9 @@ describe('Users', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Users', () => { }); 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', + $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, @@ -138,9 +138,9 @@ describe('Users', () => { }); 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', + $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, @@ -169,9 +169,9 @@ describe('Users', () => { }); 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', + $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, @@ -200,9 +200,9 @@ describe('Users', () => { }); 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', + $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, @@ -236,9 +236,9 @@ describe('Users', () => { }); 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', + $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, @@ -270,9 +270,9 @@ describe('Users', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Users', () => { }); 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', + $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, @@ -338,9 +338,9 @@ describe('Users', () => { }); 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', + $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, @@ -368,9 +368,9 @@ describe('Users', () => { }); 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', + $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, @@ -407,9 +407,9 @@ describe('Users', () => { }); 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', + $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, @@ -447,9 +447,9 @@ describe('Users', () => { }); 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', + $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, @@ -474,9 +474,9 @@ describe('Users', () => { }); 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', + $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, @@ -527,8 +527,8 @@ describe('Users', () => { }); test('test method getMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', code: '446372', @@ -650,9 +650,9 @@ describe('Users', () => { }); 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', + $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, @@ -675,11 +675,70 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys('<USER_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('<USER_ID>', '<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '<USER_ID>', + '<PASSKEY_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('<USER_ID>', '<PASSKEY_ID>'); + + // 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', + $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, @@ -704,9 +763,9 @@ describe('Users', () => { }); 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', + $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, @@ -764,9 +823,9 @@ describe('Users', () => { }); 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', + $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', @@ -824,9 +883,9 @@ describe('Users', () => { }); 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', + $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, @@ -864,9 +923,9 @@ describe('Users', () => { }); 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', + $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', @@ -888,9 +947,9 @@ describe('Users', () => { }); 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', + $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', @@ -907,9 +966,9 @@ describe('Users', () => { }); 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', + $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', @@ -936,8 +995,8 @@ describe('Users', () => { }); test('test method createToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -953,9 +1012,9 @@ describe('Users', () => { }); 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', + $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, @@ -980,9 +1039,9 @@ describe('Users', () => { }); 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', + $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, diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..4fe8681 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -26,10 +26,10 @@ describe('VectorsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('VectorsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('VectorsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -204,10 +204,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -260,10 +260,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -317,13 +317,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -422,13 +422,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -444,13 +444,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -466,13 +466,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -518,9 +518,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -544,9 +544,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -582,21 +582,17 @@ describe('VectorsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..1e672a2 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('<RULE_ID>', 'api', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '<RULE_ID>', + 'api', + '<NAME>', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '<RULE_ID>', + 'api', + '<NAME>', + '<LOCATION>', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule('<RULE_ID>'); + + // 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 7f7e54b..d232fb5 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -26,9 +26,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -55,9 +55,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -79,9 +79,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -118,9 +118,9 @@ describe('Webhooks', () => { }); 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', + $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: [], diff --git a/test/topic.test.js b/test/topic.test.js deleted file mode 100644 index 44ba8cd..0000000 --- a/test/topic.test.js +++ /dev/null @@ -1,44 +0,0 @@ -const { Topic } = require('../dist/topic'); - -describe('Topic', () => { - test('path', () => { - expect(Topic.path(['user']).toString()).toEqual('user'); - expect(Topic.path(['user', 'notification']).toString()).toEqual( - 'user/notification', - ); - expect(Topic.path(['user']).path(['notification']).toString()).toEqual( - 'user/notification', - ); - }); - test('any', () => { - expect( - Topic.path(['user']).any().path(['notification']).toString(), - ).toEqual('user/+/notification'); - expect( - Topic.path(['chat']).any().any().path(['message']).toString(), - ).toEqual('chat/+/+/message'); - expect(Topic.any().path(['notification']).toString()).toEqual( - '+/notification', - ); - }); - test('all', () => { - expect( - Topic.path(['org']).any().path(['logs']).all().toString(), - ).toEqual('org/+/logs/#'); - expect(Topic.all().toString()).toEqual('#'); - }); - test.each([ - ['an empty path', []], - ['an empty level', ['user', '']], - ['a slash', ['user/123']], - ['a lone +', ['user', '+']], - ['an embedded +', ['user', 'a+b']], - ['a lone #', ['user', '#']], - ['an embedded #', ['user', 'a#b']], - ['a non-string level', ['user', null]], - ['a non-array', 'user'], - ])('rejects %s', (_, levels) => { - expect(() => Topic.path(levels)).toThrow(Error); - expect(() => Topic.any().path(levels)).toThrow(Error); - }); -}); From d01fbf1a27fe957c5facdff90d97d38b4ad16bc1 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal <chiragaggarwal5k@gmail.com> Date: Wed, 14 Oct 2026 18:20:11 +0100 Subject: [PATCH 4/7] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 82 +- README.md | 4 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 1 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/update-email.md | 10 +- docs/examples/messaging/update-push.md | 4 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 +- .../project/update-o-auth-2-auth-0.md | 2 +- .../project/update-o-auth-2-discord.md | 2 +- .../project/update-o-auth-2-git-hub.md | 2 +- .../project/update-o-auth-2-google.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 2 +- .../project/update-o-auth-2-microsoft.md | 2 +- docs/examples/project/update-o-auth-2-okta.md | 2 +- .../project/update-o-auth-2-salesforce.md | 2 +- docs/examples/project/update-o-auth-2-zoho.md | 2 +- .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 59 +- src/enums/databases-index-type.ts | 1 + src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 2 + src/models.ts | 1135 ++- src/services/account.ts | 2254 ++++- src/services/activities.ts | 102 +- src/services/advisor.ts | 229 +- src/services/apps.ts | 633 +- src/services/backups.ts | 355 +- src/services/databases.ts | 3189 +++++-- src/services/documents-db.ts | 1179 ++- src/services/domains.ts | 1398 ++- src/services/embeddings.ts | 35 +- src/services/functions.ts | 1059 ++- src/services/locale.ts | 211 +- src/services/messaging.ts | 3171 ++++--- src/services/mongo.ts | 1672 +++- src/services/mysql.ts | 1926 +++- src/services/oauth-2.ts | 359 +- src/services/organization.ts | 735 +- src/services/postgresql.ts | 2071 ++++- src/services/presences.ts | 94 +- src/services/project.ts | 7877 +++++++++++++---- src/services/proxy.ts | 217 +- src/services/sites.ts | 979 +- src/services/storage.ts | 326 +- src/services/tables-db.ts | 3640 ++++++-- src/services/teams.ts | 380 +- src/services/tokens.ts | 142 +- src/services/users.ts | 1808 +++- src/services/vectors-db.ts | 1181 ++- src/services/waf.ts | 2415 +++++ src/services/webhooks.ts | 217 +- test/services/account.test.js | 329 +- test/services/activities.test.js | 2 +- test/services/advisor.test.js | 12 +- test/services/apps.test.js | 60 +- test/services/avatars.test.js | 6 +- test/services/backups.test.js | 42 +- test/services/databases.test.js | 310 +- test/services/documents-d-b.test.js | 172 +- test/services/domains.test.js | 162 +- test/services/functions.test.js | 94 +- test/services/messaging.test.js | 282 +- test/services/mongo.test.js | 138 +- test/services/mysql.test.js | 138 +- test/services/oauth2.test.js | 12 +- test/services/organization.test.js | 98 +- test/services/postgresql.test.js | 158 +- test/services/presences.test.js | 24 +- test/services/project.test.js | 569 +- test/services/proxy.test.js | 36 +- test/services/sites.test.js | 86 +- test/services/storage.test.js | 48 +- test/services/tables-d-b.test.js | 338 +- test/services/teams.test.js | 60 +- test/services/tokens.test.js | 12 +- test/services/users.test.js | 211 +- test/services/vectors-d-b.test.js | 144 +- test/services/waf.test.js | 354 + test/services/webhooks.test.js | 24 +- 127 files changed, 37058 insertions(+), 8627 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..c8ce6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,64 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - ## 30.0.0 -* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed -* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed -* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` -* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model -* Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `account.createIdTokenSession` and email verification and recovery OTP methods +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models +* Breaking: removed `organization.createKey`, `listKeys`, `updateKey` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys` +* Breaking: removed `BillingPlanGroup.Starter` +* Breaking: removed `Models.DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList.pricing` +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `string[]` +* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage` +* Added: `Topic` helper to build MQTT topics for push messages +* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider +* Updated: missing response fields fall back to their documented defaults +* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned + +## 29.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers -* Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics -* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + +## 29.3.1 + +* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys +* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy + +## 29.3.0 + +* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification` +* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in +* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey` +* Added: `project.updatePasskeyPolicy` to configure passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..14ec8d8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '<STATE>', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '<PASSKEY_ID>', // optional + name: '<NAME>', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '<CHALLENGE_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '<PASSKEY_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..78a1de6 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,6 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 499e392..256234c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -18,10 +18,10 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional - replyToEmail: 'email@example.com', // optional - replyToName: '<REPLY_TO_NAME>', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 04e86f7..0fc7a9a 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -10,18 +10,18 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateEmail({ messageId: '<MESSAGE_ID>', - subject: '<SUBJECT>', // optional - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional cc: [], // optional bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional replyToEmail: 'email@example.com', // optional replyToName: '<REPLY_TO_NAME>', // optional - draft: false, // optional - html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index d62e346..5d0e6b7 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -10,11 +10,11 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updatePush({ messageId: '<MESSAGE_ID>', - title: '<TITLE>', // optional - body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional data: {}, // optional action: '<ACTION>', // optional image: '<ID1:ID2>', // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 7c95f4f..940474a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,10 +10,10 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + content: '<CONTENT>', // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '<CLIENT_ID>', // optional scope: '<SCOPE>', // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '<CLIENT_SECRET>', // optional codeVerifier: '<CODE_VERIFIER>', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..c0add3b --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..5400831 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..417f5c8 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..88d3d57 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..14bb9a8 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 9319a90..e1392e0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,8 +13,8 @@ const result = await project.updateOAuth2Apple({ keyId: '<KEY_ID>', // optional teamId: '<TEAM_ID>', // optional p8File: '<P8_FILE>', // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 61fb73c..79ba89d 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional endpoint: '<ENDPOINT>', // optional - prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index d76ac95..a8d5282 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index cb497db..8d3fbdd 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 0325eef..fc081aa 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,8 +12,8 @@ const result = await project.updateOAuth2Google({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index cb310ae..af88267 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kakao({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7a7edb2..2cb3efe 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '<APPLICATION_ID>', // optional applicationSecret: '<APPLICATION_SECRET>', // optional tenant: '<TENANT>', // optional - prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 4b6deba..7f0052b 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -13,7 +13,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '<CLIENT_SECRET>', // optional domain: 'example.com', // optional authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional - prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 12698d0..ffd57c0 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '<CUSTOMER_KEY>', // optional customerSecret: '<CUSTOMER_SECRET>', // optional - prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index baa7bc8..2ccc10d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '<RP_ID>', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..2d45ad5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional + membershipId: '<MEMBERSHIP_ID>', // optional }); ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '<USER_ID>', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + location: '<LOCATION>', + statusCode: 300, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + location: '<LOCATION>', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..b36b64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..9272cdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..3012e45 100644 --- a/src/client.ts +++ b/src/client.ts @@ -44,6 +44,59 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record<string, unknown>; + properties?: Record<string, DefaultsShape>; +}; + +type Defaults = { + root: DefaultsShape; + models: Record<string, DefaultsModel>; +}; + +export function applyDefaults<T>(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record<string, DefaultsModel>, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record<string, unknown> = { ...model.defaults, ...value }; + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + // The spread drops the non-enumerable JSON toString that Client.call attaches. + if (Object.prototype.hasOwnProperty.call(value, 'toString')) { + Object.defineProperty(result, 'toString', { + value: () => JSONbig.stringify(result), + writable: true, + enumerable: false, + configurable: true, + }); + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +133,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +194,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.5.0', }; /** diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833..275668e 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4..09fd95c 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..35f0b73 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,7 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; export type { QueryTypes, QueryTypesList } from './query'; @@ -119,3 +120,4 @@ export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..a2b3d6c 100644 --- a/src/models.ts +++ b/src/models.ts @@ -25,6 +25,7 @@ import { ProxyRuleStatus } from './enums/proxy-rule-status'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +504,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +516,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -744,39 +747,39 @@ export namespace Models { /** * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ - status?: DatabaseStatus; + status?: DatabaseStatus | null; /** * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ - engine?: string; + engine?: string | null; /** * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. */ - specification?: string; + specification?: string | null; /** * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ - replicas?: number; + replicas?: number | null; /** * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. */ - error?: string; + error?: string | null; /** * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. */ - containerStatus?: string; + containerStatus?: string | null; /** * 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; + lifecycleState?: string | null; /** * Database backup policies. */ - policies?: BackupPolicy[]; + policies?: BackupPolicy[] | null; /** * Database backup archives. */ - archives?: BackupArchive[]; + archives?: BackupArchive[] | null; }; /** @@ -934,7 +937,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -950,11 +953,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -984,7 +987,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -996,15 +999,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1034,7 +1037,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1046,15 +1049,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -1084,7 +1087,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1096,15 +1099,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1134,7 +1137,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1146,7 +1149,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -1176,7 +1179,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1192,7 +1195,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1222,7 +1225,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1242,7 +1245,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1272,7 +1275,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1288,7 +1291,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1318,7 +1321,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1334,7 +1337,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1364,7 +1367,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1380,7 +1383,7 @@ export namespace Models { /** * Default value for attribute when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -1410,7 +1413,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1472,7 +1475,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1484,7 +1487,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -1514,7 +1517,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1526,7 +1529,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -1556,7 +1559,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1568,7 +1571,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -1598,7 +1601,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1614,11 +1617,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1648,7 +1651,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1660,11 +1663,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1694,7 +1697,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1706,11 +1709,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1740,7 +1743,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1752,11 +1755,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1844,7 +1847,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1882,7 +1885,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -2030,7 +2033,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2046,11 +2049,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2080,7 +2083,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2092,15 +2095,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2130,7 +2133,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2142,15 +2145,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -2180,7 +2183,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2192,15 +2195,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2230,7 +2233,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2242,7 +2245,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -2272,7 +2275,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2288,7 +2291,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2318,7 +2321,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2338,7 +2341,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2368,7 +2371,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2384,7 +2387,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2414,7 +2417,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2430,7 +2433,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2460,7 +2463,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2476,7 +2479,7 @@ export namespace Models { /** * Default value for column when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -2506,7 +2509,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2568,7 +2571,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2580,7 +2583,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -2610,7 +2613,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2622,7 +2625,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -2652,7 +2655,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2664,7 +2667,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -2694,7 +2697,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2710,11 +2713,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2744,7 +2747,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2756,11 +2759,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2790,7 +2793,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2802,11 +2805,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2836,7 +2839,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2848,11 +2851,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2898,7 +2901,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -2944,7 +2947,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -3052,7 +3055,7 @@ export namespace Models { /** * Presence status. */ - status?: string; + status?: string | null; /** * Presence source. */ @@ -3060,7 +3063,7 @@ export namespace Models { /** * Presence expiry date in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * Presence metadata. */ @@ -3092,15 +3095,15 @@ export namespace Models { /** * Hashed user password. */ - password?: string; + password?: string | null; /** * Password hashing algorithm. */ - hash?: string; + hash?: string | null; /** * Password hashing algorithm configuration. */ - hashOptions?: object; + hashOptions?: object | null; /** * User registration date in ISO 8601 format. */ @@ -3132,27 +3135,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3176,11 +3179,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3346,27 +3349,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3390,11 +3393,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3654,47 +3657,47 @@ export namespace Models { /** * City */ - city?: string; + city?: string | null; /** * Name of timezone */ - timeZone?: string; + timeZone?: string | null; /** * Postal code */ - postalCode?: string; + postalCode?: string | null; /** * Latitude */ - latitude?: number; + latitude?: number | null; /** * Longitude */ - longitude?: number; + longitude?: number | null; /** * Autonomous System Number (ASN) of the IP */ - autonomousSystemNumber?: string; + autonomousSystemNumber?: string | null; /** * Organization that owns the ASN */ - autonomousSystemOrganization?: string; + autonomousSystemOrganization?: string | null; /** * Internet service provider of the IP */ - isp?: string; + isp?: string | null; /** * Connection type of the IP (e.g. cable, cellular, corporate) */ - connectionType?: string; + connectionType?: string | null; /** * User type classification of the IP (e.g. residential, business, hosting) */ - connectionUsageType?: string; + connectionUsageType?: string | null; /** * Registered organization of the IP */ - connectionOrganization?: string; + connectionOrganization?: string | null; }; /** @@ -4201,6 +4204,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number | null; /** * Function execution timeout in seconds. */ @@ -4342,7 +4349,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile?: string; + fallbackFile?: string | null; }; /** @@ -4538,7 +4545,7 @@ export namespace Models { /** * The scheduled time for execution. If left empty, execution will be queued immediately. */ - scheduledAt?: string; + scheduledAt?: string | null; }; /** @@ -4652,87 +4659,91 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled?: boolean; + wafEnabled?: boolean | null; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * First time the project received a non-console API request. Empty until the project is used. */ - firstAccessedAt?: string; + firstAccessedAt?: string | null; /** * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. */ - mcpAccessedAt?: string; + mcpAccessedAt?: string | null; /** * OAuth2 server status */ - oAuth2ServerEnabled?: boolean; + oAuth2ServerEnabled?: boolean | null; /** * OAuth2 server authorization URL */ - oAuth2ServerAuthorizationUrl?: string; + oAuth2ServerAuthorizationUrl?: string | null; /** * OAuth2 server allowed scopes */ - oAuth2ServerScopes?: string[]; + oAuth2ServerScopes?: string[] | null; /** * OAuth2 server scopes used when an authorization request omits the scope parameter */ - oAuth2ServerDefaultScopes?: string[]; + oAuth2ServerDefaultScopes?: string[] | null; /** * Scopes an application may request when installed on a team */ - oAuth2ServerInstallationScopes?: string[]; + oAuth2ServerInstallationScopes?: string[] | null; /** * OAuth2 server accepted RFC 9396 authorization_details types */ - oAuth2ServerAuthorizationDetailsTypes?: string[]; + oAuth2ServerAuthorizationDetailsTypes?: string[] | null; /** * OAuth2 server access token duration in seconds for confidential clients */ - oAuth2ServerAccessTokenDuration?: number; + oAuth2ServerAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for confidential clients */ - oAuth2ServerRefreshTokenDuration?: number; + oAuth2ServerRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicAccessTokenDuration?: number; + oAuth2ServerPublicAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicRefreshTokenDuration?: number; + oAuth2ServerPublicRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for app installation access tokens */ - oAuth2ServerInstallationAccessTokenDuration?: number; + oAuth2ServerInstallationAccessTokenDuration?: number | null; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ - oAuth2ServerConfidentialPkce?: boolean; + oAuth2ServerConfidentialPkce?: boolean | null; /** * URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured. */ - oAuth2ServerVerificationUrl?: string; + oAuth2ServerVerificationUrl?: string | null; /** * Number of characters in the device flow user code, excluding the formatting separator. */ - oAuth2ServerUserCodeLength?: number; + oAuth2ServerUserCodeLength?: number | null; /** * Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`. */ - oAuth2ServerUserCodeFormat?: string; + oAuth2ServerUserCodeFormat?: string | null; /** * Lifetime in seconds of device flow device codes and user codes. */ - oAuth2ServerDeviceCodeDuration?: number; + oAuth2ServerDeviceCodeDuration?: number | null; /** * OAuth2 server discovery URL */ - oAuth2ServerDiscoveryUrl?: string; + oAuth2ServerDiscoveryUrl?: string | null; }; /** @@ -5898,7 +5909,7 @@ export namespace Models { /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ - maxAge?: number; + maxAge?: number | null; }; /** @@ -6251,6 +6262,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6410,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6572,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6822,7 +6873,7 @@ export namespace Models { /** * Type of deployment resource: function, site, or dedicatedDatabase. */ - deploymentResourceType?: ProxyRuleDeploymentResourceType; + deploymentResourceType?: ProxyRuleDeploymentResourceType | null; /** * ID of deployment's resource (site or function ID). Used if type is "deployment" */ @@ -6931,6 +6982,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -7058,15 +7205,15 @@ export namespace Models { /** * The scheduled time for message. */ - scheduledAt?: string; + scheduledAt?: string | null; /** * The time when the message was delivered. */ - deliveredAt?: string; + deliveredAt?: string | null; /** * Delivery errors if any. */ - deliveryErrors?: string[]; + deliveryErrors?: string[] | null; /** * Number of recipients the message was delivered to. */ @@ -7120,11 +7267,11 @@ export namespace Models { /** * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. */ - qos?: number; + qos?: number | null; /** - * Message retention in seconds for offline delivery. + * Message retention in seconds for offline delivery. Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. */ - expiry?: number; + expiry?: number | null; }; /** @@ -7226,7 +7373,7 @@ export namespace Models { /** * Provider ID. */ - providerId?: string; + providerId?: string | null; /** * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ @@ -7304,15 +7451,15 @@ export namespace Models { /** * Time the insight was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; /** * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - dismissedAt?: string; + dismissedAt?: string | null; /** * User ID that dismissed the insight. Empty when not dismissed. */ - dismissedBy?: string; + dismissedBy?: string | null; }; /** @@ -7388,7 +7535,7 @@ export namespace Models { /** * Time the report was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; }; /** @@ -7566,7 +7713,7 @@ export namespace Models { /** * Archive size in bytes. Null until the size is known. */ - size?: number; + size?: number | null; /** * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ @@ -7574,7 +7721,7 @@ export namespace Models { /** * The backup start time. Null until the backup starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -7590,11 +7737,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this archive should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this archive should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; }; /** @@ -7648,23 +7795,23 @@ export namespace Models { /** * Backup start time in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Backup completion time in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Backup verification time in ISO 8601 format. */ - verifiedAt?: string; + verifiedAt?: string | null; /** * Backup expiration time in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * 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; + logPosition?: string | null; /** * Error message if backup failed. */ @@ -7718,35 +7865,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth?: number; + bandwidth?: number | null; /** * Storage limit */ - storage?: number; + storage?: number | null; /** * Users limit */ - users?: number; + users?: number | null; /** * Executions limit */ - executions?: number; + executions?: number | null; /** * GBHours limit */ - GBHours?: number; + GBHours?: number | null; /** * Image transformations limit */ - imageTransformations?: number; + imageTransformations?: number | null; /** * Auth phone limit */ - authPhone?: number; + authPhone?: number | null; /** * Budget limit percentage */ - budgetLimit?: number; + budgetLimit?: number | null; }; /** @@ -7796,7 +7943,7 @@ export namespace Models { /** * Members */ - members?: number; + members?: number | null; /** * Webhooks */ @@ -7805,6 +7952,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments: number; /** * Projects */ @@ -7892,7 +8043,7 @@ export namespace Models { /** * Activity log days */ - activityLogs?: number; + activityLogs?: number | null; /** * Usage history days */ @@ -7900,11 +8051,11 @@ export namespace Models { /** * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ - usageLogsIntervals?: string[]; + usageLogsIntervals?: string[] | null; /** * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. */ - usageAggregateOnlyMetrics?: string[]; + usageAggregateOnlyMetrics?: string[] | null; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -7916,7 +8067,7 @@ export namespace Models { /** * Additional resources. Null when the plan does not support usage billing. */ - usage?: UsageBillingPlan; + usage?: UsageBillingPlan | null; /** * Addons */ @@ -7944,7 +8095,7 @@ export namespace Models { /** * ISO country codes eligible for this regional plan. Empty means no restriction. */ - eligibleCountries?: string[]; + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8000,7 +8151,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled?: boolean; + backupsEnabled?: boolean | null; /** * Whether usage addons are calculated per project. */ @@ -8012,7 +8163,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies?: number; + backupPolicies?: number | null; /** * Maximum function and site deployment size in MB */ @@ -8021,6 +8172,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8028,7 +8183,7 @@ export namespace Models { /** * Plan specific limits */ - limits?: BillingPlanLimits; + limits?: BillingPlanLimits | null; /** * Group of this billing plan for variants */ @@ -8036,7 +8191,7 @@ export namespace Models { /** * Details of the program this plan is a part of. */ - program?: Program; + program?: Program | null; /** * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. */ @@ -8044,7 +8199,7 @@ export namespace Models { /** * Dedicated database limits available to this plan. */ - dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; + dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits | null; }; /** @@ -8054,11 +8209,11 @@ export namespace Models { /** * Addon seats */ - seats?: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails | null; /** * Addon projects */ - projects?: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails | null; }; /** @@ -8084,7 +8239,7 @@ export namespace Models { /** * Price currency */ - currency?: string; + currency?: string | null; /** * Price */ @@ -8106,11 +8261,11 @@ export namespace Models { /** * Credits limit per billing cycle */ - credits?: number; + credits?: number | null; /** * Daily credits limit (if applicable) */ - dailyCredits?: number; + dailyCredits?: number | null; }; /** @@ -8120,79 +8275,79 @@ export namespace Models { /** * Minimum CPU allocation in millicores. */ - minCpu?: number; + minCpu?: number | null; /** * Maximum CPU allocation in millicores. */ - maxCpu?: number; + maxCpu?: number | null; /** * Minimum memory allocation in megabytes. */ - minMemoryMb?: number; + minMemoryMb?: number | null; /** * Maximum memory allocation in megabytes. */ - maxMemoryMb?: number; + maxMemoryMb?: number | null; /** * Minimum storage allocation in gigabytes. */ - minStorageGb?: number; + minStorageGb?: number | null; /** * Maximum storage allocation in gigabytes. */ - maxStorageGb?: number; + maxStorageGb?: number | null; /** * Maximum number of high-availability replicas per dedicated database. */ - maxReplicas?: number; + maxReplicas?: number | null; /** * Maximum number of client connections. */ - maxConnections?: number; + maxConnections?: number | null; /** * Maximum number of entries allowed in the IP allowlist. */ - maxIpAllowlistSize?: number; + maxIpAllowlistSize?: number | null; /** * Maximum number of database extensions that can be enabled. */ - maxExtensions?: number; + maxExtensions?: number | null; /** * Maximum number of days a backup can be retained. */ - maxBackupRetentionDays?: number; + maxBackupRetentionDays?: number | null; /** * Maximum number of days of point-in-time recovery data that can be retained. */ - maxPitrRetentionDays?: number; + maxPitrRetentionDays?: number | null; /** * Maximum number of rows a single SQL API query can return. */ - maxSqlApiMaxRows?: number; + maxSqlApiMaxRows?: number | null; /** * Maximum response size in bytes for a single SQL API query. */ - maxSqlApiMaxBytes?: number; + maxSqlApiMaxBytes?: number | null; /** * Maximum execution time in seconds for a single SQL API query. */ - maxSqlApiTimeoutSeconds?: number; + maxSqlApiTimeoutSeconds?: number | null; /** * Maximum number of SQL statement types that can be permitted through the SQL API. */ - maxSqlApiAllowedStatements?: number; + maxSqlApiAllowedStatements?: number | null; /** * SQL statement types permitted through the SQL API. */ - allowedSqlStatements?: string[]; + allowedSqlStatements?: string[] | null; /** * Storage classes available for dedicated databases. */ - allowedStorageClasses?: string[]; + allowedStorageClasses?: string[] | null; /** * Replica synchronization modes available for dedicated databases. */ - allowedSyncModes?: string[]; + allowedSyncModes?: string[] | null; }; /** @@ -8236,7 +8391,7 @@ export namespace Models { /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - expiredAt?: string; + expiredAt?: string | null; }; /** @@ -8266,7 +8421,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number | null; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8563,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string | null; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string | null; /** * Database engine version. */ @@ -8432,7 +8587,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number | null; /** * Database username for connections. */ @@ -8444,7 +8599,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number | null; /** * Full database connection string (URI format). */ @@ -8464,11 +8619,11 @@ export namespace Models { /** * Last activity timestamp in ISO 8601 format. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; /** * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. */ - idleUntil?: string; + idleUntil?: string | null; /** * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. */ @@ -8500,7 +8655,7 @@ export namespace Models { /** * Time the in-flight storage resize started, in ISO 8601 format. */ - storageResizeStartedAt?: string; + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8658,7 +8813,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string | null; /** * Project ID. */ @@ -8666,7 +8821,7 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string | null; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ @@ -8678,15 +8833,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string | null; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string | null; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string | null; /** * Error message if restoration failed. */ @@ -8720,7 +8875,7 @@ export namespace Models { /** * Connection statistics. Null when the database has not been probed. */ - connections?: DatabaseStatusConnections; + connections?: DatabaseStatusConnections | null; /** * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. */ @@ -8728,7 +8883,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -8744,7 +8899,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -8856,7 +9011,7 @@ export namespace Models { /** * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus?: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum | null; /** * Team ID. */ @@ -8886,7 +9041,7 @@ export namespace Models { /** * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price?: number; + price?: number | null; /** * Price period in years. */ @@ -8898,7 +9053,7 @@ export namespace Models { /** * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. */ - renewalPrice?: number; + renewalPrice?: number | null; /** * Renewal price period in years. */ @@ -8960,11 +9115,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -8998,15 +9153,15 @@ export namespace Models { /** * Time the operation was requested, in ISO 8601 format. */ - requestedAt?: string; + requestedAt?: string | null; /** * Time the operation started, in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Time the operation reached a terminal state, in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ @@ -9046,7 +9201,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -9062,7 +9217,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * Per-pod statuses for the primary and every replica. */ @@ -9124,7 +9279,7 @@ export namespace Models { /** * Project budget limit. Null when no budget is set. */ - billingBudget?: number; + billingBudget?: number | null; /** * Project budget limit */ @@ -9148,43 +9303,43 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string | null; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string | null; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string | null; /** * Start date of trial. */ - billingTrialStartDate?: string; + billingTrialStartDate?: string | null; /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number | null; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string | null; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string | null; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string | null; /** * Default payment method. */ - billingAddressId?: string; + billingAddressId?: string | null; /** * Backup payment method. */ - backupPaymentMethodId?: string; + backupPaymentMethodId?: string | null; /** * Team status. */ @@ -9192,39 +9347,39 @@ export namespace Models { /** * Remarks on team status. */ - remarks?: string; + remarks?: string | null; /** * Organization agreements */ - agreementBAA?: string; + agreementBAA?: string | null; /** * Program manager's name. */ - programManagerName?: string; + programManagerName?: string | null; /** * Program manager's calendar link. */ - programManagerCalendar?: string; + programManagerCalendar?: string | null; /** * Program's discord channel name. */ - programDiscordChannelName?: string; + programDiscordChannelName?: string | null; /** * Program's discord channel URL. */ - programDiscordChannelUrl?: string; + programDiscordChannelUrl?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * Billing plan selected for downgrade. */ - billingPlanDowngrade?: string; + billingPlanDowngrade?: string | null; /** * Tax Id */ - billingTaxId?: string; + billingTaxId?: string | null; /** * Marked for deletion */ @@ -9284,11 +9439,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this policy should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this policy should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; /** * How many days to keep the backup before it will be automatically deleted. */ @@ -9448,7 +9603,7 @@ export namespace Models { /** * The restoration start time. Null until the restoration starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -9586,11 +9741,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -9622,47 +9777,47 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource | null; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource | null; /** * Member additional resources */ - member?: AdditionalResource; + member?: AdditionalResource | null; /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource | null; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource | null; /** * Realtime bandwidth additional resources */ - realtimeBandwidth?: AdditionalResource; + realtimeBandwidth?: AdditionalResource | null; /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource | null; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource | null; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource | null; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource | null; /** * Credits additional resources */ - credits?: AdditionalResource; + credits?: AdditionalResource | null; }; /** @@ -9814,7 +9969,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9856,7 +10011,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9928,7 +10083,7 @@ export namespace Models { /** * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9970,7 +10125,7 @@ export namespace Models { /** * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -10132,11 +10287,11 @@ export namespace Models { /** * Granted RFC 9396 authorization details as a JSON string. */ - authorization_details?: string; + authorization_details?: string | null; /** * OpenID Connect ID token. Returned when the `openid` scope is granted. */ - id_token?: string; + id_token?: string | null; }; /** @@ -10150,47 +10305,47 @@ export namespace Models { /** * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. */ - token_use?: string; + token_use?: string | null; /** * OAuth2 token type. */ - token_type?: string; + token_type?: string | null; /** * Space-separated scopes granted to the token. */ - scope?: string; + scope?: string | null; /** * OAuth2 client ID the token was issued to. */ - client_id?: string; + client_id?: string | null; /** * ID of the user who authorized the token. */ - sub?: string; + sub?: string | null; /** * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). */ - aud?: string[]; + aud?: string[] | null; /** * Issuer URL of the token. */ - iss?: string; + iss?: string | null; /** * Expiration time as a Unix timestamp in seconds. */ - exp?: number; + exp?: number | null; /** * Issued-at time as a Unix timestamp in seconds. */ - iat?: number; + iat?: number | null; /** * Unique identifier of the token. */ - jti?: string; + jti?: string | null; /** * Granted RFC 9396 authorization details, restricted to what the user can currently access. */ - authorization_details?: Record<string, any>[]; + authorization_details?: Record<string, any>[] | null; }; /** @@ -10289,6 +10444,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..a321bd6 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +186,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +297,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + consents: [], + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +542,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +648,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +824,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +935,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1084,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1185,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1348,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1470,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1684,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1850,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1966,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2026,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2061,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2097,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2128,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2161,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2193,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2226,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2258,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2330,538 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.PasskeyList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise<Models.PasskeyChallenge>; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise<Models.PasskeyChallenge>; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise<Models.PasskeyChallenge> { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { passkeyId: string }): Promise<Models.Passkey>; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise<Models.Passkey> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise<Models.Passkey>; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise<Models.Passkey>; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2940,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3062,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3189,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3300,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3411,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3502,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3611,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3679,58 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3802,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2389,14 +3852,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. - * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ createEmailPasswordSession(params: { email: string; password: string; - duration?: number; + duration?: number | null; }): Promise<Models.Session>; /** * 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. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. @@ -2405,7 +3868,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. - * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2413,14 +3876,19 @@ export class Account { createEmailPasswordSession( email: string, password: string, - duration?: number, + duration?: number | null, ): Promise<Models.Session>; createEmailPasswordSession( paramsOrFirst: - { email: string; password: string; duration?: number } | string, - ...rest: [string?, number?] + | { email: string; password: string; duration?: number | null } + | string, + ...rest: [string?, (number | null)?] ): Promise<Models.Session> { - let params: { email: string; password: string; duration?: number }; + let params: { + email: string; + password: string; + duration?: number | null; + }; if ( paramsOrFirst && @@ -2430,13 +3898,13 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; - duration?: number; + duration?: number | null; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, - duration: rest[1] as number, + duration: rest[1] as number | null, }; } @@ -2470,7 +3938,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4140,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4255,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4367,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4478,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4573,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4669,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4785,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4919,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5043,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5076,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} */ @@ -3259,6 +5085,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise<string>; /** * 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. @@ -3273,6 +5100,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5110,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise<string>; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5119,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise<string> { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5139,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5155,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5163,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5183,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5196,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskeyToken(): Promise<Models.PasskeyChallenge> { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise<Models.TokenSecret>; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise<Models.TokenSecret>; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.TokenSecret> { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5396,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5473,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5551,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5642,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5731,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5808,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5901,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5938,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6029,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..d082ca4 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,58 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + events: [], + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +171,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..303b910 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,76 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + reports: [], + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +206,65 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +405,56 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +526,44 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..ff362ed 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,72 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + apps: [], + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +450,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +523,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +569,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +647,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1019,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1206,38 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1311,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1478,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1575,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1659,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1738,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1889,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2024,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2108,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2195,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2345,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..8efb7f2 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,41 +64,71 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + archives: [], + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} params.services - Array of services to backup - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} */ createArchive(params: { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }): Promise<Models.BackupArchive>; /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} services - Array of services to backup - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} * @deprecated Use the object parameter style method for a better developer experience. */ createArchive( services: BackupServices[], - resourceId?: string, + resourceId?: string | null, ): Promise<Models.BackupArchive>; createArchive( paramsOrFirst: - | { services: BackupServices[]; resourceId?: string } + | { services: BackupServices[]; resourceId?: string | null } | BackupServices[], - ...rest: [string?] + ...rest: [(string | null)?] ): Promise<Models.BackupArchive> { - let params: { services: BackupServices[]; resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string | null }; if ( paramsOrFirst && @@ -103,12 +138,12 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string, + resourceId: rest[0] as string | null, }; } @@ -135,7 +170,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +244,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +370,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +413,7 @@ export class Backups { * @param {number} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Schedule CRON syntax. * @param {string} params.name - Policy name. Max length: 128 chars. - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -319,7 +424,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }): Promise<Models.BackupPolicy>; /** @@ -330,7 +435,7 @@ export class Backups { * @param {number} retention - Days to keep backups before deletion * @param {string} schedule - Schedule CRON syntax. * @param {string} name - Policy name. Max length: 128 chars. - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -342,7 +447,7 @@ export class Backups { retention: number, schedule: string, name?: string, - resourceId?: string, + resourceId?: string | null, enabled?: boolean, ): Promise<Models.BackupPolicy>; createPolicy( @@ -353,7 +458,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; } | string, @@ -362,7 +467,7 @@ export class Backups { number?, string?, string?, - string?, + (string | null)?, boolean?, ] ): Promise<Models.BackupPolicy> { @@ -372,7 +477,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; @@ -387,7 +492,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; } else { @@ -397,7 +502,7 @@ export class Backups { retention: rest[1] as number, schedule: rest[2] as string, name: rest[3] as string, - resourceId: rest[4] as string, + resourceId: rest[4] as string | null, enabled: rest[5] as boolean, }; } @@ -460,7 +565,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,64 +641,90 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update an existing policy using it's ID. * * @param {string} params.policyId - Policy ID. Choose a custom ID`. 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 {number} params.retention - Days to keep backups before deletion + * @param {string | null} params.name - Policy name. Max length: 128 chars. + * @param {number | null} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Cron expression - * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updatePolicy(params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * Update an existing policy using it's ID. * * @param {string} policyId - Policy ID. Choose a custom ID`. 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 {number} retention - Days to keep backups before deletion + * @param {string | null} name - Policy name. Max length: 128 chars. + * @param {number | null} retention - Days to keep backups before deletion * @param {string} schedule - Cron expression - * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePolicy( policyId: string, - name?: string, - retention?: number, + name?: string | null, + retention?: number | null, schedule?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updatePolicy( paramsOrFirst: | { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, number?, string?, boolean?] + ...rest: [ + (string | null)?, + (number | null)?, + string?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -582,18 +734,18 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { policyId: paramsOrFirst as string, - name: rest[0] as string, - retention: rest[1] as number, + name: rest[0] as string | null, + retention: rest[1] as number | null, schedule: rest[2] as string, - enabled: rest[3] as boolean, + enabled: rest[3] as boolean | null, }; } @@ -632,7 +784,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +987,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1061,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1150,27 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..0b2d328 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,69 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +246,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +366,35 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +447,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +522,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +629,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +779,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +852,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +988,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1199,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -892,11 +1259,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. @@ -905,7 +1272,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -917,11 +1284,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,7 +1297,7 @@ export class Databases { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -942,7 +1309,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -952,7 +1319,7 @@ export class Databases { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -963,7 +1330,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -979,7 +1346,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -990,7 +1357,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1053,7 +1420,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1537,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1139,7 +1586,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1151,7 +1598,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1162,7 +1609,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1174,7 +1621,7 @@ export class Databases { databaseId: string, collectionId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1185,19 +1632,26 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Collection> { let params: { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1212,7 +1666,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1222,7 +1676,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -1276,7 +1730,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1955,20 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + attributes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1472,9 +1979,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1485,9 +1992,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeBigint>; /** @@ -1498,9 +2005,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1511,9 +2018,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeBigint>; createBigIntAttribute( @@ -1523,9 +2030,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -1533,9 +2040,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeBigint> { @@ -1544,9 +2051,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -1560,9 +2067,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -1571,9 +2078,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -1638,7 +2145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,10 +2173,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. @@ -1662,10 +2186,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeBigint>; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. @@ -1675,10 +2199,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1688,10 +2212,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeBigint>; updateBigIntAttribute( paramsOrFirst: @@ -1700,20 +2224,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeBigint> { let params: { @@ -1721,10 +2245,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -1737,10 +2261,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -1748,10 +2272,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -1818,7 +2342,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1829,7 +2370,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1840,7 +2381,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.AttributeBoolean>; /** @@ -1851,7 +2392,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1862,7 +2403,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.AttributeBoolean>; createBooleanAttribute( @@ -1872,18 +2413,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -1897,7 +2438,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -1906,7 +2447,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -1963,7 +2504,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1973,8 +2531,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. @@ -1984,8 +2542,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.AttributeBoolean>; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -1994,8 +2552,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2005,8 +2563,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.AttributeBoolean>; updateBooleanAttribute( paramsOrFirst: @@ -2015,19 +2573,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2040,8 +2604,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2049,8 +2613,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2109,7 +2673,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2119,7 +2700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2130,7 +2711,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeDatetime>; /** @@ -2140,7 +2721,7 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2151,7 +2732,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeDatetime>; createDatetimeAttribute( @@ -2161,18 +2742,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2186,7 +2767,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2195,7 +2776,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2252,7 +2833,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2262,8 +2860,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. @@ -2273,8 +2871,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeDatetime>; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -2283,8 +2881,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2294,8 +2892,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeDatetime>; updateDatetimeAttribute( paramsOrFirst: @@ -2304,19 +2902,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2329,8 +2933,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2338,8 +2942,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2398,7 +3002,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2409,7 +3030,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2420,7 +3041,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEmail>; /** @@ -2431,7 +3052,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2442,7 +3063,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEmail>; createEmailAttribute( @@ -2452,18 +3073,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2477,7 +3098,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2486,7 +3107,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2543,7 +3164,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2554,8 +3193,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. @@ -2565,8 +3204,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEmail>; /** * Update an email attribute. Changing the `default` value will not update already existing documents. @@ -2576,8 +3215,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2587,8 +3226,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEmail>; updateEmailAttribute( paramsOrFirst: @@ -2597,19 +3236,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2622,8 +3267,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2631,8 +3276,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2691,7 +3336,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2703,7 +3366,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2715,7 +3378,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEnum>; /** @@ -2727,7 +3390,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2739,7 +3402,7 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEnum>; createEnumAttribute( @@ -2750,11 +3413,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2762,7 +3432,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2777,7 +3447,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2787,7 +3457,7 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -2853,7 +3523,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2865,8 +3554,8 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. @@ -2877,8 +3566,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEnum>; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -2889,8 +3578,8 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2901,8 +3590,8 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEnum>; updateEnumAttribute( paramsOrFirst: @@ -2912,11 +3601,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2924,8 +3620,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2939,8 +3635,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2949,8 +3645,8 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3018,7 +3714,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3029,9 +3744,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3042,9 +3757,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.AttributeFloat>; /** @@ -3055,9 +3770,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3068,9 +3783,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.AttributeFloat>; createFloatAttribute( @@ -3080,9 +3795,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3090,9 +3805,9 @@ export class Databases { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.AttributeFloat> { @@ -3101,9 +3816,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3117,9 +3832,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3128,9 +3843,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3195,7 +3910,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3206,10 +3938,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {string} params.newKey - New Attribute Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. @@ -3219,10 +3951,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.AttributeFloat>; /** * Update a float attribute. Changing the `default` value will not update already existing documents. @@ -3232,10 +3964,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {string} newKey - New Attribute Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3245,10 +3977,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.AttributeFloat>; updateFloatAttribute( paramsOrFirst: @@ -3257,20 +3989,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.AttributeFloat> { let params: { @@ -3278,10 +4010,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3294,10 +4026,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3305,10 +4037,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -3375,7 +4107,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3386,9 +4135,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3399,9 +4148,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeInteger>; /** @@ -3412,9 +4161,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3425,9 +4174,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeInteger>; createIntegerAttribute( @@ -3437,9 +4186,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -3447,9 +4196,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeInteger> { @@ -3458,9 +4207,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -3474,9 +4223,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -3485,9 +4234,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -3552,7 +4301,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,10 +4329,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. @@ -3576,10 +4342,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeInteger>; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -3589,10 +4355,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3602,10 +4368,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeInteger>; updateIntegerAttribute( paramsOrFirst: @@ -3614,20 +4380,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeInteger> { let params: { @@ -3635,10 +4401,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -3651,10 +4417,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -3662,10 +4428,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -3732,7 +4498,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3743,7 +4526,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3754,7 +4537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeIp>; /** @@ -3765,7 +4548,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3776,7 +4559,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeIp>; createIpAttribute( @@ -3786,18 +4569,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3811,7 +4594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3820,7 +4603,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3877,7 +4660,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3888,8 +4689,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. @@ -3899,8 +4700,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeIp>; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -3910,8 +4711,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3921,8 +4722,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeIp>; updateIpAttribute( paramsOrFirst: @@ -3931,19 +4732,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3956,8 +4763,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3965,8 +4772,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4025,7 +4832,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4035,7 +4860,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. @@ -4045,7 +4870,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributeLine>; /** * Create a geometric line attribute. @@ -4054,7 +4879,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4064,7 +4889,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributeLine>; createLineAttribute( paramsOrFirst: @@ -4073,17 +4898,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4096,7 +4921,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4104,7 +4929,7 @@ export class Databases { 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[][] | null, }; } @@ -4156,7 +4981,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4166,8 +5008,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. @@ -4177,8 +5019,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributeLine>; /** * Update a line attribute. Changing the `default` value will not update already existing documents. @@ -4187,8 +5029,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4198,8 +5040,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributeLine>; updateLineAttribute( paramsOrFirst: @@ -4208,19 +5050,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4233,8 +5081,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4242,8 +5090,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4297,7 +5145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4308,7 +5173,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4320,7 +5185,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeLongtext>; @@ -4332,7 +5197,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4344,7 +5209,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeLongtext>; @@ -4355,19 +5220,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4382,7 +5254,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4392,7 +5264,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4454,7 +5326,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4465,8 +5354,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. @@ -4476,8 +5365,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeLongtext>; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -4487,8 +5376,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4498,8 +5387,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeLongtext>; updateLongtextAttribute( paramsOrFirst: @@ -4508,19 +5397,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4533,8 +5428,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4542,8 +5437,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4602,7 +5497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4613,7 +5525,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4625,7 +5537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeMediumtext>; @@ -4637,7 +5549,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4649,7 +5561,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeMediumtext>; @@ -4660,19 +5572,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4687,7 +5606,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4697,7 +5616,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4759,7 +5678,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4770,8 +5706,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. @@ -4781,8 +5717,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeMediumtext>; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -4792,8 +5728,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4803,8 +5739,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeMediumtext>; updateMediumtextAttribute( paramsOrFirst: @@ -4813,19 +5749,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4838,8 +5780,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4847,8 +5789,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4907,7 +5849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4917,7 +5876,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. @@ -4927,7 +5886,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.AttributePoint>; /** * Create a geometric point attribute. @@ -4936,7 +5895,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4946,7 +5905,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.AttributePoint>; createPointAttribute( paramsOrFirst: @@ -4955,17 +5914,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -4978,7 +5937,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -4986,7 +5945,7 @@ export class Databases { 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[] | null, }; } @@ -5038,7 +5997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5048,8 +6024,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. @@ -5059,8 +6035,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.AttributePoint>; /** * Update a point attribute. Changing the `default` value will not update already existing documents. @@ -5069,8 +6045,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5080,8 +6056,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.AttributePoint>; updatePointAttribute( paramsOrFirst: @@ -5090,19 +6066,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5115,8 +6097,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5124,8 +6106,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5179,7 +6161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5189,7 +6188,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. @@ -5199,7 +6198,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributePolygon>; /** * Create a geometric polygon attribute. @@ -5208,7 +6207,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5218,7 +6217,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributePolygon>; createPolygonAttribute( paramsOrFirst: @@ -5227,17 +6226,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5250,7 +6249,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5258,7 +6257,7 @@ export class Databases { 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[][] | null, }; } @@ -5310,7 +6309,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5320,8 +6336,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. @@ -5331,8 +6347,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributePolygon>; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -5341,8 +6357,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5352,8 +6368,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributePolygon>; updatePolygonAttribute( paramsOrFirst: @@ -5362,19 +6378,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -5387,8 +6409,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -5396,8 +6418,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -5451,7 +6473,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5463,8 +6502,8 @@ export class Databases { * @param {string} params.relatedCollectionId - Related Collection ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Attribute Key. - * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {string | null} params.key - Attribute Key. + * @param {string | null} params.twoWayKey - Two Way Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5476,8 +6515,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.AttributeRelationship>; /** @@ -5489,8 +6528,8 @@ export class Databases { * @param {string} relatedCollectionId - Related Collection ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Attribute Key. - * @param {string} twoWayKey - Two Way Attribute Key. + * @param {string | null} key - Attribute Key. + * @param {string | null} twoWayKey - Two Way Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5502,8 +6541,8 @@ export class Databases { relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.AttributeRelationship>; createRelationshipAttribute( @@ -5514,8 +6553,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -5524,8 +6563,8 @@ export class Databases { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.AttributeRelationship> { @@ -5535,8 +6574,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -5551,8 +6590,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -5562,8 +6601,8 @@ export class Databases { relatedCollectionId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -5628,7 +6667,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5639,7 +6700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. @@ -5649,7 +6710,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }): Promise<Models.AttributeRelationship>; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -5659,7 +6720,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Attribute Key. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5669,7 +6730,7 @@ export class Databases { collectionId: string, key: string, onDelete?: RelationMutate, - newKey?: string, + newKey?: string | null, ): Promise<Models.AttributeRelationship>; updateRelationshipAttribute( paramsOrFirst: @@ -5678,17 +6739,17 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, RelationMutate?, (string | null)?] ): Promise<Models.AttributeRelationship> { let params: { databaseId: string; collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; if ( @@ -5701,7 +6762,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; } else { params = { @@ -5709,7 +6770,7 @@ export class Databases { 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 | null, }; } @@ -5754,7 +6815,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5766,7 +6849,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for text attributes, in number of characters. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5779,7 +6862,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeString>; @@ -5792,7 +6875,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for text attributes, in number of characters. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5805,7 +6888,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeString>; @@ -5817,7 +6900,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -5827,7 +6910,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -5838,7 +6921,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5854,7 +6937,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5865,7 +6948,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -5934,7 +7017,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5945,9 +7046,9 @@ export class Databases { * @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). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the string attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the string attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. @@ -5957,9 +7058,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeString>; /** * Update a string attribute. Changing the `default` value will not update already existing documents. @@ -5969,9 +7070,9 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the string attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the string attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5981,9 +7082,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeString>; updateStringAttribute( paramsOrFirst: @@ -5992,21 +7093,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeString> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6019,9 +7127,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6029,9 +7137,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6094,7 +7202,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6105,7 +7231,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6117,7 +7243,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeText>; @@ -6129,7 +7255,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6141,7 +7267,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeText>; @@ -6152,19 +7278,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6179,7 +7312,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6189,7 +7322,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6251,7 +7384,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6262,8 +7412,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6273,8 +7423,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeText>; /** * Update a text attribute. Changing the `default` value will not update already existing documents. @@ -6284,8 +7434,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6295,8 +7445,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeText>; updateTextAttribute( paramsOrFirst: @@ -6305,19 +7455,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6330,8 +7486,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6339,8 +7495,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6399,7 +7555,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7583,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6421,7 +7594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeUrl>; /** @@ -6432,7 +7605,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6443,7 +7616,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeUrl>; createUrlAttribute( @@ -6453,18 +7626,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -6478,7 +7651,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -6487,7 +7660,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -6544,7 +7717,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6555,8 +7746,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. @@ -6566,8 +7757,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeUrl>; /** * Update an url attribute. Changing the `default` value will not update already existing documents. @@ -6577,8 +7768,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6588,8 +7779,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeUrl>; updateUrlAttribute( paramsOrFirst: @@ -6598,19 +7789,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6623,8 +7820,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6632,8 +7829,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6692,7 +7889,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6704,7 +7919,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6717,7 +7932,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeVarchar>; @@ -6730,7 +7945,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6743,7 +7958,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeVarchar>; @@ -6755,7 +7970,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6765,7 +7980,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6776,7 +7991,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6792,7 +8007,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6803,7 +8018,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6872,7 +8087,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6883,9 +8116,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the varchar attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the varchar attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. @@ -6895,9 +8128,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeVarchar>; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -6907,9 +8140,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the varchar attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the varchar attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6919,9 +8152,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeVarchar>; updateVarcharAttribute( paramsOrFirst: @@ -6930,21 +8163,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeVarchar> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6957,9 +8197,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6967,9 +8207,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7032,7 +8272,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8664,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7416,8 +8703,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. @@ -7431,8 +8718,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -7441,8 +8728,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7454,8 +8741,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7467,8 +8754,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -7478,8 +8765,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -7490,8 +8777,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -7507,8 +8794,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -7519,8 +8806,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -7576,7 +8863,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7585,7 +8890,7 @@ export class Databases { * @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. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. @@ -7596,7 +8901,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7604,7 +8909,7 @@ export class Databases { * @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. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7613,7 +8918,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; createDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7621,16 +8926,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7642,14 +8947,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7694,7 +8999,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7704,7 +9038,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. @@ -7715,7 +9049,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7724,7 +9058,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7733,7 +9067,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7741,16 +9075,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7762,14 +9096,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7814,7 +9148,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7824,7 +9187,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. @@ -7836,7 +9199,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7845,7 +9208,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7855,7 +9218,7 @@ export class Databases { collectionId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; updateDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7864,17 +9227,17 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7887,7 +9250,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -7895,7 +9258,7 @@ export class Databases { 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 | null, }; } @@ -7939,7 +9302,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9444,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9603,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8192,8 +9631,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. @@ -8208,8 +9647,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -8218,8 +9657,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8232,8 +9671,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; upsertDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8245,8 +9684,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8256,8 +9695,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8268,8 +9707,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8285,8 +9724,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8297,8 +9736,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8352,7 +9791,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8362,8 +9819,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. @@ -8378,8 +9835,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -8388,8 +9845,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8402,8 +9859,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; updateDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8415,8 +9872,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8426,8 +9883,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8438,8 +9895,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8455,8 +9912,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8467,8 +9924,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8522,7 +9979,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8650,8 +10125,8 @@ export class Databases { * @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.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. + * @param {number | null} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. @@ -8664,8 +10139,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Decrement a specific attribute of a document by a given value. @@ -8675,8 +10150,8 @@ export class Databases { * @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} 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. + * @param {number | null} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8689,8 +10164,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Document>; decrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8702,11 +10177,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8714,8 +10196,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -8729,8 +10211,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8739,8 +10221,8 @@ export class Databases { 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, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8798,7 +10280,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8809,8 +10309,8 @@ export class Databases { * @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. + * @param {number | null} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. @@ -8823,8 +10323,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Increment a specific attribute of a document by a given value. @@ -8834,8 +10334,8 @@ export class Databases { * @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. + * @param {number | null} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8848,8 +10348,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Document>; incrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8861,11 +10361,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8873,8 +10380,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -8888,8 +10395,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8898,8 +10405,8 @@ export class Databases { 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, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8957,7 +10464,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,12 +10592,42 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9096,7 +10651,7 @@ export class Databases { }): Promise<Models.Index>; /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9234,7 +10789,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10898,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..8d1f7f6 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,69 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class DocumentsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class DocumentsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class DocumentsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1384,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -988,7 +1396,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1000,7 +1408,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -1013,7 +1421,7 @@ export class DocumentsDB { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -1025,7 +1433,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1035,7 +1443,7 @@ export class DocumentsDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1046,7 +1454,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1062,7 +1470,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1073,7 +1481,7 @@ export class DocumentsDB { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1136,7 +1544,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1660,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1848,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2097,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2295,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2430,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2578,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2731,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2872,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +3030,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3217,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3404,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3696,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3872,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3999,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4195,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4303,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3570,33 +4419,33 @@ export class DocumentsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3605,12 +4454,12 @@ export class DocumentsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3637,7 +4486,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4646,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4733,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4817,51 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..12834f0 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,62 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + domains: [], + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +199,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +334,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +443,35 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + prices: [], + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +524,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +699,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +803,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +904,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +1000,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1091,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1185,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1276,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1370,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1461,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1555,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1646,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1740,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1829,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1923,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2031,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2193,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2359,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2510,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2676,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2829,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2999,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3150,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3316,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3473,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3635,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3786,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3952,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4124,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4303,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4454,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4622,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4822,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5066,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5216,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5384,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5485,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5659,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5760,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5906,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..baf425d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,32 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + embeddings: [], + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..9e141da 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,78 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + functions: [], + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +179,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +196,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -150,6 +223,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise<Models.Function>; /** * 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. @@ -159,7 +233,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +250,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +278,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise<Models.Function>; create( paramsOrFirst: @@ -229,6 +305,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +330,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise<Models.Function> { let params: { @@ -278,6 +356,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +387,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +413,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +439,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +521,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +532,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +643,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + runtimes: [], + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + supports: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +741,33 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +822,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +893,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -640,15 +901,16 @@ export class Functions { * @param {string} params.commands - Build Commands. * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the function deployments. - * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} params.buildSpecification - Build specification for the function deployments. + * @param {string | null} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -666,15 +928,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }): Promise<Models.Function>; /** * Update function by its unique ID. @@ -684,7 +947,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -692,15 +955,16 @@ export class Functions { * @param {string} commands - Build Commands. * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the function deployments. - * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} buildSpecification - Build specification for the function deployments. + * @param {string | null} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -719,15 +983,16 @@ export class Functions { commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, - runtimeSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, + runtimeSpecification?: string | null, deploymentRetention?: number, + interval?: number | null, ): Promise<Models.Function>; update( paramsOrFirst: @@ -745,15 +1010,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; } | string, ...rest: [ @@ -769,15 +1035,16 @@ export class Functions { string?, ProjectKeyScopes[]?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, number?, + (number | null)?, ] ): Promise<Models.Function> { let params: { @@ -794,15 +1061,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }; if ( @@ -824,15 +1092,16 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; }; } else { params = { @@ -849,15 +1118,16 @@ export class Functions { commands: rest[9] as string, scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, + providerRepositoryId: rest[12] as string | null, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - providerBranches: rest[16] as string[], - providerPaths: rest[17] as string[], - buildSpecification: rest[18] as string, - runtimeSpecification: rest[19] as string, + providerBranches: rest[16] as string[] | null, + providerPaths: rest[17] as string[] | null, + buildSpecification: rest[18] as string | null, + runtimeSpecification: rest[19] as string | null, deploymentRetention: rest[20] as number, + interval: rest[21] as number | null, }; } @@ -883,6 +1153,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1230,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1241,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1433,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1597,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1892,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2102,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2256,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2369,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2673,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2794,59 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2858,7 @@ export class Functions { * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ @@ -2190,7 +2869,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Execution>; /** * 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. @@ -2201,7 +2880,7 @@ export class Functions { * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2213,7 +2892,7 @@ export class Functions { xpath?: string, method?: ExecutionMethod, headers?: object, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Execution>; createExecution( paramsOrFirst: @@ -2224,7 +2903,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; } | string, ...rest: [ @@ -2233,7 +2912,7 @@ export class Functions { string?, ExecutionMethod?, object?, - string?, + (string | null)?, ] ): Promise<Models.Execution> { let params: { @@ -2243,7 +2922,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -2258,7 +2937,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -2268,7 +2947,7 @@ 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 | null, }; } @@ -2315,7 +2994,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3108,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3304,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3462,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3554,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2752,27 +3581,27 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2780,28 +3609,33 @@ export class Functions { updateVariable( functionId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2812,17 +3646,17 @@ export class Functions { params = (paramsOrFirst || {}) as { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2862,7 +3696,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..ca069ee 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + localeCodes: [], + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +170,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + continents: [], + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +245,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +320,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +397,32 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + phones: [], + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +473,36 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + currencies: [], + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +553,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + languages: [], + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..2bc0b35 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,39 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + messages: [], + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,12 +137,12 @@ export class Messaging { * @param {string[]} params.targets - List of Targets IDs. * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -118,12 +155,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }): Promise<Models.Message>; /** * Create a new email message. @@ -136,12 +173,12 @@ export class Messaging { * @param {string[]} targets - List of Targets IDs. * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -155,12 +192,12 @@ export class Messaging { targets?: string[], cc?: string[], bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, + attachments?: string[] | null, draft?: boolean, html?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, + replyToEmail?: string, + replyToName?: string, ): Promise<Models.Message>; createEmail( paramsOrFirst: @@ -173,12 +210,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -189,11 +226,11 @@ export class Messaging { string[]?, string[]?, string[]?, - string[]?, - string?, - string?, + (string[] | null)?, boolean?, boolean?, + (string | null)?, + string?, string?, ] ): Promise<Models.Message> { @@ -206,12 +243,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -228,12 +265,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -245,12 +282,12 @@ export class Messaging { targets: rest[4] as string[], cc: rest[5] as string[], bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + attachments: rest[7] as string[] | null, + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string | null, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -263,11 +300,11 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; - const replyToEmail = params.replyToEmail; - const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -312,12 +349,6 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } - if (typeof replyToEmail !== 'undefined') { - apiPayload['replyToEmail'] = replyToEmail; - } - if (typeof replyToName !== 'undefined') { - apiPayload['replyToName'] = replyToName; - } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -327,6 +358,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -335,7 +372,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,126 +401,126 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.subject - Email Subject. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {string[]} params.cc - Array of target IDs to be added as CC. - * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} params.draft - Is message a draft - * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.subject - Email Subject. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {boolean | null} params.html - Is content of type HTML + * @param {string[] | null} params.cc - Array of target IDs to be added as CC. + * @param {string[] | null} params.bcc - Array of target IDs to be added as BCC. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.Message>; /** * 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} subject - Email Subject. - * @param {string} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {string[]} cc - Array of target IDs to be added as CC. - * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} draft - Is message a draft - * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} subject - Email Subject. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {boolean | null} html - Is content of type HTML + * @param {string[] | null} cc - Array of target IDs to be added as CC. + * @param {string[] | null} bcc - Array of target IDs to be added as BCC. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateEmail( messageId: string, - subject?: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - cc?: string[], - bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, - draft?: boolean, - html?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + subject?: string | null, + content?: string | null, + draft?: boolean | null, + html?: boolean | null, + cc?: string[] | null, + bcc?: string[] | null, + scheduledAt?: string | null, + attachments?: string[] | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.Message>; updateEmail( paramsOrFirst: | { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string?, - string?, - boolean?, - boolean?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.Message> { let params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -472,53 +530,53 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - subject: rest[0] as string, - content: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - cc: rest[5] as string[], - bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + subject: rest[3] as string | null, + content: rest[4] as string | null, + draft: rest[5] as boolean | null, + html: rest[6] as boolean | null, + cc: rest[7] as string[] | null, + bcc: rest[8] as string[] | null, + scheduledAt: rest[9] as string | null, + attachments: rest[10] as string[] | null, + replyToEmail: rest[11] as string | null, + replyToName: rest[12] as string | null, }; } const messageId = params.messageId; - const subject = params.subject; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; const cc = params.cc; const bcc = params.bcc; + const scheduledAt = params.scheduledAt; const attachments = params.attachments; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - const draft = params.draft; - const html = params.html; - const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -529,12 +587,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof subject !== 'undefined') { - apiPayload['subject'] = subject; - } - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -544,12 +596,27 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof subject !== 'undefined') { + apiPayload['subject'] = subject; + } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + if (typeof draft !== 'undefined') { + apiPayload['draft'] = draft; + } + if (typeof html !== 'undefined') { + apiPayload['html'] = html; + } if (typeof cc !== 'undefined') { apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { apiPayload['bcc'] = bcc; } + if (typeof scheduledAt !== 'undefined') { + apiPayload['scheduledAt'] = scheduledAt; + } if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } @@ -559,15 +626,6 @@ export class Messaging { if (typeof replyToName !== 'undefined') { apiPayload['replyToName'] = replyToName; } - if (typeof draft !== 'undefined') { - apiPayload['draft'] = draft; - } - if (typeof html !== 'undefined') { - apiPayload['html'] = html; - } - if (typeof scheduledAt !== 'undefined') { - apiPayload['scheduledAt'] = scheduledAt; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -576,7 +634,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -588,7 +667,7 @@ export class Messaging { * @param {string[]} params.topics - List of Topic IDs. * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional key-value pair data for push notification. + * @param {object | null} params.data - Additional key-value pair data for push notification. * @param {string} params.action - Action for push notification. * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. @@ -597,7 +676,7 @@ export class Messaging { * @param {string} params.tag - Tag for push notification. Available only for Android Platform. * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -612,7 +691,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -621,7 +700,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -636,7 +715,7 @@ export class Messaging { * @param {string[]} topics - List of Topic IDs. * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional key-value pair data for push notification. + * @param {object | null} data - Additional key-value pair data for push notification. * @param {string} action - Action for push notification. * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. @@ -645,7 +724,7 @@ export class Messaging { * @param {string} tag - Tag for push notification. Available only for Android Platform. * @param {number} badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -661,7 +740,7 @@ export class Messaging { topics?: string[], users?: string[], targets?: string[], - data?: object, + data?: object | null, action?: string, image?: string, icon?: string, @@ -670,7 +749,7 @@ export class Messaging { tag?: string, badge?: number, draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, @@ -685,7 +764,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -694,7 +773,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -707,7 +786,7 @@ export class Messaging { string[]?, string[]?, string[]?, - object?, + (object | null)?, string?, string?, string?, @@ -716,7 +795,7 @@ export class Messaging { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, MessagePriority?, @@ -730,7 +809,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -739,7 +818,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -758,7 +837,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -767,7 +846,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -781,7 +860,7 @@ export class Messaging { topics: rest[2] as string[], users: rest[3] as string[], targets: rest[4] as string[], - data: rest[5] as object, + data: rest[5] as object | null, action: rest[6] as string, image: rest[7] as string, icon: rest[8] as string, @@ -790,7 +869,7 @@ export class Messaging { tag: rest[11] as string, badge: rest[12] as number, draft: rest[13] as boolean, - scheduledAt: rest[14] as string, + scheduledAt: rest[14] as string | null, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, @@ -893,7 +972,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -901,168 +1001,168 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.title - Title for push notification. - * @param {string} params.body - Body for push notification. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional Data for push notification. - * @param {string} params.action - Action for push notification. - * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} params.color - Color for push notification. Available only for Android platforms. - * @param {string} params.tag - Tag for push notification. Available only for Android platforms. - * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.title - Title for push notification. + * @param {string | null} params.body - Body for push notification. + * @param {object | null} params.data - Additional Data for push notification. + * @param {string | null} params.action - Action for push notification. + * @param {string | null} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} params.color - Color for push notification. Available only for Android platforms. + * @param {string | null} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }): Promise<Models.Message>; /** * 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} title - Title for push notification. - * @param {string} body - Body for push notification. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional Data for push notification. - * @param {string} action - Action for push notification. - * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} color - Color for push notification. Available only for Android platforms. - * @param {string} tag - Tag for push notification. Available only for Android platforms. - * @param {number} badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} title - Title for push notification. + * @param {string | null} body - Body for push notification. + * @param {object | null} data - Additional Data for push notification. + * @param {string | null} action - Action for push notification. + * @param {string | null} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} color - Color for push notification. Available only for Android platforms. + * @param {string | null} tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePush( 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, - channelId?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + title?: string | null, + body?: string | null, + data?: object | null, + action?: string | null, + image?: string | null, + icon?: string | null, + sound?: string | null, + color?: string | null, + tag?: string | null, + badge?: number | null, + draft?: boolean | null, + scheduledAt?: string | null, + contentAvailable?: boolean | null, + critical?: boolean | null, + priority?: MessagePriority | null, + channelId?: string | null, ): Promise<Models.Message>; updatePush( 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - object?, - string?, - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string?, - boolean?, - boolean?, - MessagePriority?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (object | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (MessagePriority | null)?, + (string | null)?, ] ): Promise<Models.Message> { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; if ( @@ -1072,57 +1172,57 @@ export class Messaging { ) { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - title: rest[0] as string, - body: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - data: rest[5] as object, - action: rest[6] as string, - image: rest[7] as string, - icon: rest[8] as string, - sound: rest[9] as string, - color: rest[10] as string, - tag: rest[11] as string, - badge: rest[12] as number, - draft: rest[13] as boolean, - scheduledAt: rest[14] as string, - contentAvailable: rest[15] as boolean, - critical: rest[16] as boolean, - priority: rest[17] as MessagePriority, - channelId: rest[18] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + title: rest[3] as string | null, + body: rest[4] as string | null, + data: rest[5] as object | null, + action: rest[6] as string | null, + image: rest[7] as string | null, + icon: rest[8] as string | null, + sound: rest[9] as string | null, + color: rest[10] as string | null, + tag: rest[11] as string | null, + badge: rest[12] as number | null, + draft: rest[13] as boolean | null, + scheduledAt: rest[14] as string | null, + contentAvailable: rest[15] as boolean | null, + critical: rest[16] as boolean | null, + priority: rest[17] as MessagePriority | null, + channelId: rest[18] as string | null, }; } const messageId = params.messageId; - const title = params.title; - const body = params.body; const topics = params.topics; const users = params.users; const targets = params.targets; + const title = params.title; + const body = params.body; const data = params.data; const action = params.action; const image = params.image; @@ -1147,12 +1247,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof title !== 'undefined') { - apiPayload['title'] = title; - } - if (typeof body !== 'undefined') { - apiPayload['body'] = body; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1162,6 +1256,12 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof title !== 'undefined') { + apiPayload['title'] = title; + } + if (typeof body !== 'undefined') { + apiPayload['body'] = body; + } if (typeof data !== 'undefined') { apiPayload['data'] = data; } @@ -1212,7 +1312,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1224,7 +1345,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. @@ -1236,7 +1357,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1247,7 +1368,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1259,7 +1380,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSms( paramsOrFirst: @@ -1270,10 +1391,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1282,7 +1410,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1297,7 +1425,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1307,7 +1435,7 @@ 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 | null, }; } @@ -1359,7 +1487,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1371,7 +1520,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -1382,7 +1531,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1393,7 +1542,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1405,7 +1554,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSMS( paramsOrFirst: @@ -1416,10 +1565,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1428,7 +1584,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1443,7 +1599,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1453,7 +1609,7 @@ 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 | null, }; } @@ -1505,7 +1661,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1513,71 +1690,78 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ updateSms(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSms( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSms( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1587,30 +1771,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1623,9 +1807,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1635,6 +1816,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1649,7 +1833,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1657,70 +1862,77 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSMS(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSMS( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSMS( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1730,30 +1942,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1766,9 +1978,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1778,6 +1987,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1792,7 +2004,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2082,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: [], + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2240,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2349,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + providers: [], + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2078,7 +2392,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. @@ -2091,7 +2405,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2103,7 +2417,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2116,7 +2430,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createApnsProvider( paramsOrFirst: @@ -2128,7 +2442,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2138,7 +2452,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2149,7 +2463,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2165,7 +2479,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2176,7 +2490,7 @@ 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 | null, }; } @@ -2230,7 +2544,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2243,7 +2576,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -2255,7 +2588,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2267,7 +2600,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2280,7 +2613,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createAPNSProvider( paramsOrFirst: @@ -2292,7 +2625,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2302,7 +2635,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2313,7 +2646,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2329,7 +2662,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2340,7 +2673,7 @@ 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 | null, }; } @@ -2394,7 +2727,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2402,12 +2754,12 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. @@ -2415,24 +2767,24 @@ export class Messaging { updateApnsProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2440,45 +2792,45 @@ export class Messaging { updateApnsProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateApnsProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2489,23 +2841,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2556,7 +2908,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2564,36 +2935,36 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAPNSProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2601,45 +2972,45 @@ export class Messaging { updateAPNSProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateAPNSProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2650,23 +3021,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2717,7 +3088,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2725,27 +3115,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createAppwriteProvider(params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Create a new Appwrite push provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2753,28 +3143,33 @@ export class Messaging { createAppwriteProvider( providerId: string, name: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; createAppwriteProvider( paramsOrFirst: | { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2785,17 +3180,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2837,7 +3232,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,27 +3259,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAppwriteProvider(params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Update an Appwrite push provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2873,28 +3287,33 @@ export class Messaging { updateAppwriteProvider( providerId: string, name?: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; updateAppwriteProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2905,17 +3324,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2954,7 +3373,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2962,8 +3400,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. @@ -2971,16 +3409,16 @@ export class Messaging { createFcmProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2988,25 +3426,25 @@ export class Messaging { createFcmProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFcmProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3017,15 +3455,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3063,7 +3501,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3071,24 +3528,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFCMProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3096,25 +3553,25 @@ export class Messaging { createFCMProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFCMProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3125,15 +3582,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3171,7 +3628,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,8 +3655,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. @@ -3188,16 +3664,16 @@ export class Messaging { updateFcmProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3205,25 +3681,25 @@ export class Messaging { updateFcmProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFcmProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3234,15 +3710,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3277,7 +3753,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3285,24 +3780,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFCMProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3310,25 +3805,25 @@ export class Messaging { updateFCMProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFCMProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3339,15 +3834,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3382,7 +3877,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3392,12 +3906,12 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.isEuRegion - Set as EU region. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3406,12 +3920,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Mailgun provider. @@ -3420,12 +3934,12 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean | null} isEuRegion - Set as EU region. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3435,12 +3949,12 @@ export class Messaging { name: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, + isEuRegion?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMailgunProvider( paramsOrFirst: @@ -3449,24 +3963,24 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -3474,12 +3988,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3492,12 +4006,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3505,12 +4019,12 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, + isEuRegion: rest[3] as boolean | null, fromName: rest[4] as string, 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 | null, }; } @@ -3572,7 +4086,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3582,8 +4115,8 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3596,8 +4129,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3610,8 +4143,8 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} isEuRegion - Set as EU region. + * @param {boolean | null} enabled - Set as enabled. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3625,8 +4158,8 @@ export class Messaging { name?: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, - enabled?: boolean, + isEuRegion?: boolean | null, + enabled?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, @@ -3639,8 +4172,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3651,8 +4184,8 @@ export class Messaging { string?, string?, string?, - boolean?, - boolean?, + (boolean | null)?, + (boolean | null)?, string?, string?, string?, @@ -3664,8 +4197,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3682,8 +4215,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3695,8 +4228,8 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, - enabled: rest[4] as boolean, + isEuRegion: rest[3] as boolean | null, + enabled: rest[4] as boolean | null, fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, @@ -3759,7 +4292,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3770,7 +4322,7 @@ export class Messaging { * @param {string} params.templateId - Msg91 template ID * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3780,7 +4332,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new MSG91 provider. @@ -3790,7 +4342,7 @@ export class Messaging { * @param {string} templateId - Msg91 template ID * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3801,7 +4353,7 @@ export class Messaging { templateId?: string, senderId?: string, authKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMsg91Provider( paramsOrFirst: @@ -3811,10 +4363,10 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -3822,7 +4374,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3836,7 +4388,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3845,7 +4397,7 @@ 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 | null, }; } @@ -3891,7 +4443,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3899,7 +4470,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.templateId - Msg91 template ID. * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. @@ -3909,7 +4480,7 @@ export class Messaging { updateMsg91Provider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3919,7 +4490,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} templateId - Msg91 template ID. * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. @@ -3930,7 +4501,7 @@ export class Messaging { updateMsg91Provider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, templateId?: string, senderId?: string, authKey?: string, @@ -3940,18 +4511,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3965,7 +4536,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3974,7 +4545,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, templateId: rest[2] as string, senderId: rest[3] as string, authKey: rest[4] as string, @@ -4020,7 +4591,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4033,7 +4623,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4045,7 +4635,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Resend provider. @@ -4057,7 +4647,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4070,7 +4660,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createResendProvider( paramsOrFirst: @@ -4082,7 +4672,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4092,7 +4682,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4103,7 +4693,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4119,7 +4709,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4130,7 +4720,7 @@ 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 | null, }; } @@ -4184,7 +4774,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4192,7 +4801,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Resend API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4204,7 +4813,7 @@ export class Messaging { updateResendProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4216,7 +4825,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Resend API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4229,7 +4838,7 @@ export class Messaging { updateResendProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4241,7 +4850,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4251,7 +4860,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4262,7 +4871,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4278,7 +4887,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4289,7 +4898,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4345,7 +4954,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4358,7 +4986,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4370,7 +4998,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Sendgrid provider. @@ -4382,7 +5010,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4395,7 +5023,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSendgridProvider( paramsOrFirst: @@ -4407,7 +5035,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4417,7 +5045,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4428,7 +5056,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4444,7 +5072,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4455,7 +5083,7 @@ 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 | null, }; } @@ -4509,7 +5137,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4517,7 +5164,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Sendgrid API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4529,7 +5176,7 @@ export class Messaging { updateSendgridProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4541,7 +5188,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Sendgrid API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4554,7 +5201,7 @@ export class Messaging { updateSendgridProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4566,7 +5213,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4576,7 +5223,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4587,7 +5234,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4603,7 +5250,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4614,7 +5261,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4670,7 +5317,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4685,7 +5351,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4699,7 +5365,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Amazon SES provider. @@ -4713,7 +5379,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4728,7 +5394,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSesProvider( paramsOrFirst: @@ -4742,7 +5408,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4754,7 +5420,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4767,7 +5433,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4785,7 +5451,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4798,7 +5464,7 @@ 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 | null, }; } @@ -4860,7 +5526,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4868,7 +5553,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accessKey - AWS access key ID. * @param {string} params.secretKey - AWS secret access key. * @param {string} params.region - AWS region, for example us-east-1. @@ -4882,7 +5567,7 @@ export class Messaging { updateSesProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4896,7 +5581,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accessKey - AWS access key ID. * @param {string} secretKey - AWS secret access key. * @param {string} region - AWS region, for example us-east-1. @@ -4911,7 +5596,7 @@ export class Messaging { updateSesProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accessKey?: string, secretKey?: string, region?: string, @@ -4925,7 +5610,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4937,7 +5622,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4950,7 +5635,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4968,7 +5653,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4981,7 +5666,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accessKey: rest[2] as string, secretKey: rest[3] as string, region: rest[4] as string, @@ -5047,7 +5732,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5066,7 +5770,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. @@ -5085,7 +5789,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5103,7 +5807,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5122,7 +5826,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSmtpProvider( paramsOrFirst: @@ -5140,7 +5844,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5156,7 +5860,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5173,7 +5877,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5195,7 +5899,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5212,7 +5916,7 @@ 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 | null, }; } @@ -5293,7 +5997,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5312,7 +6035,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5330,7 +6053,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5348,7 +6071,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5367,7 +6090,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSMTPProvider( paramsOrFirst: @@ -5385,7 +6108,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5401,7 +6124,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5418,7 +6141,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5440,7 +6163,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5457,7 +6180,7 @@ 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 | null, }; } @@ -5538,7 +6261,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5547,17 +6289,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. @@ -5566,17 +6308,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5584,17 +6326,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5603,17 +6345,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSmtpProvider( paramsOrFirst: @@ -5621,50 +6363,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5676,34 +6418,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -5778,7 +6520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5787,17 +6548,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5805,17 +6566,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5823,17 +6584,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5842,17 +6603,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSMTPProvider( paramsOrFirst: @@ -5860,50 +6621,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5915,34 +6676,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -6017,7 +6778,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6028,7 +6808,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6038,7 +6818,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Telesign provider. @@ -6048,7 +6828,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6059,7 +6839,7 @@ export class Messaging { from?: string, customerId?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTelesignProvider( paramsOrFirst: @@ -6069,10 +6849,10 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6080,7 +6860,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6094,7 +6874,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6103,7 +6883,7 @@ 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 | null, }; } @@ -6149,7 +6929,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6157,7 +6956,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. * @param {string} params.from - Sender number. @@ -6167,7 +6966,7 @@ export class Messaging { updateTelesignProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6177,7 +6976,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. * @param {string} from - Sender number. @@ -6188,7 +6987,7 @@ export class Messaging { updateTelesignProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, customerId?: string, apiKey?: string, from?: string, @@ -6198,18 +6997,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6223,7 +7022,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6232,7 +7031,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, customerId: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6278,7 +7077,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6289,7 +7107,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6299,7 +7117,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Textmagic provider. @@ -6309,7 +7127,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6320,7 +7138,7 @@ export class Messaging { from?: string, username?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTextmagicProvider( paramsOrFirst: @@ -6330,10 +7148,10 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6341,7 +7159,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6355,7 +7173,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6364,7 +7182,7 @@ 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 | null, }; } @@ -6410,7 +7228,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6418,7 +7255,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. * @param {string} params.from - Sender number. @@ -6428,7 +7265,7 @@ export class Messaging { updateTextmagicProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6438,7 +7275,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. * @param {string} from - Sender number. @@ -6449,7 +7286,7 @@ export class Messaging { updateTextmagicProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, username?: string, apiKey?: string, from?: string, @@ -6459,18 +7296,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6484,7 +7321,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6493,7 +7330,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, username: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6539,7 +7376,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6550,7 +7406,7 @@ export class Messaging { * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6560,7 +7416,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Twilio provider. @@ -6570,7 +7426,7 @@ export class Messaging { * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6581,7 +7437,7 @@ export class Messaging { from?: string, accountSid?: string, authToken?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTwilioProvider( paramsOrFirst: @@ -6591,10 +7447,10 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6602,7 +7458,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6616,7 +7472,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6625,7 +7481,7 @@ 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 | null, }; } @@ -6671,7 +7527,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6679,7 +7554,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6689,7 +7564,7 @@ export class Messaging { updateTwilioProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6699,7 +7574,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6710,7 +7585,7 @@ export class Messaging { updateTwilioProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accountSid?: string, authToken?: string, from?: string, @@ -6720,18 +7595,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6745,7 +7620,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6754,7 +7629,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accountSid: rest[2] as string, authToken: rest[3] as string, from: rest[4] as string, @@ -6800,7 +7675,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6811,7 +7705,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6821,7 +7715,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Vonage provider. @@ -6831,7 +7725,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6842,7 +7736,7 @@ export class Messaging { from?: string, apiKey?: string, apiSecret?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createVonageProvider( paramsOrFirst: @@ -6852,10 +7746,10 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6863,7 +7757,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6877,7 +7771,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6886,7 +7780,7 @@ 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 | null, }; } @@ -6932,7 +7826,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6940,7 +7853,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. * @param {string} params.from - Sender number. @@ -6950,7 +7863,7 @@ export class Messaging { updateVonageProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -6960,7 +7873,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. * @param {string} from - Sender number. @@ -6971,7 +7884,7 @@ export class Messaging { updateVonageProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, apiSecret?: string, from?: string, @@ -6981,18 +7894,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7006,7 +7919,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7015,7 +7928,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, apiSecret: rest[3] as string, from: rest[4] as string, @@ -7061,7 +7974,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +8050,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8204,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + topics: [], + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7262,8 +8243,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ @@ -7271,8 +8252,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Create a new topic. @@ -7280,8 +8261,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7290,8 +8271,8 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, - expiry?: number, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; createTopic( paramsOrFirst: @@ -7299,18 +8280,18 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [string?, string[]?, (number | null)?, (number | null)?] ): Promise<Models.Topic> { let params: { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7322,16 +8303,16 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7373,7 +8354,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7438,58 +8457,63 @@ export class Messaging { * * * @param {string} params.topicId - Topic ID. - * @param {string} params.name - Topic Name. - * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} params.name - Topic Name. + * @param {string[] | null} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Update a topic by its unique ID. * * * @param {string} topicId - Topic ID. - * @param {string} name - Topic Name. - * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} name - Topic Name. + * @param {string[] | null} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. */ updateTopic( topicId: string, - name?: string, - subscribe?: string[], - qos?: number, - expiry?: number, + name?: string | null, + subscribe?: string[] | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; updateTopic( paramsOrFirst: | { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [ + (string | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Topic> { let params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7499,18 +8523,18 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, - name: rest[0] as string, - subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + name: rest[0] as string | null, + subscribe: rest[1] as string[] | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7549,7 +8573,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8750,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + subscribers: [], + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8875,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8972,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..41c0a19 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,74 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mongo { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mongo { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mongo { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mongo { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mongo { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,40 +2620,59 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2045,12 +2681,12 @@ export class Mongo { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2077,7 +2713,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2861,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2177,21 +2925,21 @@ export class Mongo { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2199,18 +2947,22 @@ export class Mongo { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2221,13 +2973,13 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2263,7 +3015,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3175,37 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3262,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3332,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,7 +3477,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2605,27 +3514,27 @@ export class Mongo { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2633,28 +3542,28 @@ export class Mongo { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -2665,17 +3574,17 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -2714,7 +3623,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3717,25 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3790,52 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +3913,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..582b5ba 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,74 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mysql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mysql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mysql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mysql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2620,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2011,24 +2647,24 @@ export class Mysql { * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** * 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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Mysql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,40 +2747,68 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2153,12 +2817,12 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2185,7 +2849,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2997,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2285,21 +3061,21 @@ export class Mysql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2307,18 +3083,22 @@ export class Mysql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2329,13 +3109,13 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2371,7 +3151,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3311,37 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3398,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,97 +3468,118 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2689,26 +3589,26 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2763,7 +3663,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3741,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,7 +3886,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2944,27 +3923,27 @@ export class Mysql { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2972,28 +3951,28 @@ export class Mysql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -3004,17 +3983,17 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -3053,7 +4032,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4126,25 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4199,52 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4322,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..84e0c31 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -347,9 +377,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -365,9 +395,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -383,9 +413,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -402,9 +432,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -420,9 +450,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -436,9 +466,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, string?, ] @@ -453,9 +483,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -476,9 +506,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -493,9 +523,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2DeviceAuthorization>; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2DeviceAuthorization>; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise<Models.Oauth2DeviceAuthorization> { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + organizations: [], + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -999,9 +1140,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1016,9 +1157,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2PAR>; /** @@ -1033,9 +1174,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1051,9 +1192,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2PAR>; createPAR( @@ -1068,9 +1209,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1083,9 +1224,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, ] ): Promise<Models.Oauth2PAR> { @@ -1099,9 +1240,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1120,9 +1261,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1136,9 +1277,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1363,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1457,32 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1540,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1671,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1494,7 +1685,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2Token>; /** @@ -1508,7 +1699,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1523,7 +1714,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2Token>; createToken( @@ -1537,7 +1728,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1740,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise<Models.Oauth2Token> { @@ -1562,7 +1753,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1771,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1784,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1846,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..3ea45e7 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +330,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,40 +407,64 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. */ updateInstallation( installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: - { installationId: string; authorizationDetails?: string } | string, - ...rest: [string?] + | { installationId: string; authorizationDetails?: string | null } + | string, + ...rest: [(string | null)?] ): Promise<Models.AppInstallation> { - let params: { installationId: string; authorizationDetails?: string }; + let params: { + installationId: string; + authorizationDetails?: string | null; + }; if ( paramsOrFirst && @@ -345,12 +473,12 @@ export class Organization { ) { params = (paramsOrFirst || {}) as { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string, + authorizationDetails: rest[0] as string | null, }; } @@ -377,7 +505,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +660,44 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +824,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +905,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1007,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1168,92 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1340,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1469,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1616,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1827,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1964,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2052,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1441,7 +2082,7 @@ export class Organization { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -1450,7 +2091,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -1459,7 +2100,7 @@ export class Organization { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1469,7 +2110,7 @@ export class Organization { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateProjectKey( paramsOrFirst: @@ -1478,17 +2119,17 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { projectId: string; keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -1501,7 +2142,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } else { params = { @@ -1509,7 +2150,7 @@ export class Organization { keyId: rest[0] as string, name: rest[1] as string, scopes: rest[2] as ProjectKeyScopes[], - expire: rest[3] as string, + expire: rest[3] as string | null, }; } @@ -1553,7 +2194,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..881da09 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,74 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Postgresql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Postgresql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Postgresql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Postgresql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,7 +2620,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2011,24 +2647,24 @@ export class Postgresql { * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** * 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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Postgresql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,7 +2747,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2834,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + metadata: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2937,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,40 +3070,96 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2365,12 +3168,12 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2397,7 +3200,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3348,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2497,21 +3412,21 @@ export class Postgresql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2519,18 +3434,22 @@ export class Postgresql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2541,13 +3460,13 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2583,7 +3502,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3662,37 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3749,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,97 +3819,118 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2901,26 +3940,26 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2975,7 +4014,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4092,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,7 +4237,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3156,27 +4274,27 @@ export class Postgresql { * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + * @param {string | null} 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<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3184,28 +4302,28 @@ export class Postgresql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, (string | null)?, (string | null)?, (string | null)?] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; if ( @@ -3216,17 +4334,17 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, }; } @@ -3265,7 +4383,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4477,25 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4550,52 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4673,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..edc7fe1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,35 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + presences: [], + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +176,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +330,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +493,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..586a6c4 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +148,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -81,7 +160,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -144,7 +223,719 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.ProjectList>; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise<Models.ProjectList>; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.ProjectList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + getEnvironment(params: { environmentId: string }): Promise<Models.Project>; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise<Models.Project>; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<Models.Project> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -209,7 +1000,38 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +1114,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +1185,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -352,7 +1214,7 @@ export class Project { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -360,7 +1222,7 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -368,7 +1230,7 @@ export class Project { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -377,7 +1239,7 @@ export class Project { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateKey( paramsOrFirst: @@ -385,16 +1247,16 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -406,14 +1268,14 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } 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 | null, }; } @@ -452,7 +1314,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +1440,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +1582,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + mockNumbers: [], + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1676,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1827,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1962,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + providers: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -945,16 +1985,16 @@ export class Project { * @param {string} params.authorizationUrl - URL to your application with consent screen. * @param {string[]} params.scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -965,16 +2005,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }): Promise<Models.Project>; @@ -985,16 +2025,16 @@ export class Project { * @param {string} authorizationUrl - URL to your application with consent screen. * @param {string[]} scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -1006,16 +2046,16 @@ export class Project { authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], - accessTokenDuration?: number, - refreshTokenDuration?: number, - publicAccessTokenDuration?: number, - publicRefreshTokenDuration?: number, - installationAccessTokenDuration?: number, - confidentialPkce?: boolean, + accessTokenDuration?: number | null, + refreshTokenDuration?: number | null, + publicAccessTokenDuration?: number | null, + publicRefreshTokenDuration?: number | null, + installationAccessTokenDuration?: number | null, + confidentialPkce?: boolean | null, verificationUrl?: string, - userCodeLength?: number, + userCodeLength?: number | null, userCodeFormat?: string, - deviceCodeDuration?: number, + deviceCodeDuration?: number | null, defaultScopes?: string[], installationScopes?: string[], ): Promise<Models.Project>; @@ -1026,16 +2066,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; } @@ -1044,16 +2084,16 @@ export class Project { string?, string[]?, string[]?, - number?, - number?, - number?, - number?, - number?, - boolean?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, string?, - number?, + (number | null)?, string?, - number?, + (number | null)?, string[]?, string[]?, ] @@ -1063,16 +2103,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1087,16 +2127,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1106,16 +2146,16 @@ export class Project { authorizationUrl: rest[0] as string, scopes: rest[1] as string[], authorizationDetailsTypes: rest[2] as string[], - accessTokenDuration: rest[3] as number, - refreshTokenDuration: rest[4] as number, - publicAccessTokenDuration: rest[5] as number, - publicRefreshTokenDuration: rest[6] as number, - installationAccessTokenDuration: rest[7] as number, - confidentialPkce: rest[8] as boolean, + accessTokenDuration: rest[3] as number | null, + refreshTokenDuration: rest[4] as number | null, + publicAccessTokenDuration: rest[5] as number | null, + publicRefreshTokenDuration: rest[6] as number | null, + installationAccessTokenDuration: rest[7] as number | null, + confidentialPkce: rest[8] as boolean | null, verificationUrl: rest[9] as string, - userCodeLength: rest[10] as number, + userCodeLength: rest[10] as number | null, userCodeFormat: rest[11] as string, - deviceCodeDuration: rest[12] as number, + deviceCodeDuration: rest[12] as number | null, defaultScopes: rest[13] as string[], installationScopes: rest[14] as string[], }; @@ -1208,48 +2248,127 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Amazon configuration. * - * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} */ updateOAuth2Amazon(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Amazon>; /** * Update the project OAuth2 Amazon configuration. * - * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Amazon( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Amazon>; updateOAuth2Amazon( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Amazon> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1259,15 +2378,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1293,76 +2412,99 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Apple configuration. * - * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} */ updateOAuth2Apple(params?: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Apple>; /** * Update the project OAuth2 Apple configuration. * - * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Apple( - serviceId?: string, - keyId?: string, - teamId?: string, - p8File?: string, - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + serviceId?: string | null, + keyId?: string | null, + teamId?: string | null, + p8File?: string | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Apple>; updateOAuth2Apple( paramsOrFirst?: | { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Apple> { let params: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -1372,23 +2514,23 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - serviceId: paramsOrFirst as string, - keyId: rest[0] as string, - teamId: rest[1] as string, - p8File: rest[2] as string, - nativeClientIds: rest[3] as string[], - enabled: rest[4] as boolean, - nativeEnabled: rest[5] as boolean, + serviceId: paramsOrFirst as string | null, + keyId: rest[0] as string | null, + teamId: rest[1] as string | null, + p8File: rest[2] as string | null, + enabled: rest[3] as boolean | null, + nativeClientIds: rest[4] as string[] | null, + nativeEnabled: rest[5] as boolean | null, }; } @@ -1396,8 +2538,8 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; @@ -1413,12 +2555,12 @@ export class Project { if (typeof p8File !== 'undefined') { apiPayload['p8File'] = p8File; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -1430,48 +2572,72 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} */ updateOAuth2Appwrite(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Appwrite>; /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Appwrite( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Appwrite>; updateOAuth2Appwrite( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Appwrite> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1481,15 +2647,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1515,64 +2681,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} */ updateOAuth2Auth0(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }): Promise<Models.OAuth2Auth0>; /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Auth0( - clientId?: string, - clientSecret?: string, - endpoint?: string, - prompt?: ProjectOAuth2Auth0Prompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2Auth0Prompt[] | null, ): Promise<Models.OAuth2Auth0>; updateOAuth2Auth0( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2Auth0Prompt[] | null)?, + ] ): Promise<Models.OAuth2Auth0> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; if ( @@ -1582,27 +2769,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - prompt: rest[2] as ProjectOAuth2Auth0Prompt[], - enabled: rest[3] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1614,12 +2801,12 @@ export class Project { if (typeof endpoint !== 'undefined') { apiPayload['endpoint'] = endpoint; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1628,58 +2815,76 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Authentik configuration. * - * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} */ updateOAuth2Authentik(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Authentik>; /** * Update the project OAuth2 Authentik configuration. * - * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Authentik( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Authentik>; updateOAuth2Authentik( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Authentik> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -1689,17 +2894,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -1729,48 +2934,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} */ updateOAuth2Autodesk(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Autodesk>; /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Autodesk( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Autodesk>; updateOAuth2Autodesk( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Autodesk> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1780,15 +3006,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1814,44 +3040,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} */ updateOAuth2Bitbucket(params?: { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitbucket>; /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitbucket( - key?: string, - secret?: string, - enabled?: boolean, + key?: string | null, + secret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitbucket>; updateOAuth2Bitbucket( paramsOrFirst?: - { key?: string; secret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitbucket> { - let params: { key?: string; secret?: string; enabled?: boolean }; + let params: { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -1860,15 +3111,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }; } else { params = { - key: paramsOrFirst as string, - secret: rest[0] as string, - enabled: rest[1] as boolean, + key: paramsOrFirst as string | null, + secret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1894,48 +3145,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitly configuration. * - * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} */ updateOAuth2Bitly(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitly>; /** * Update the project OAuth2 Bitly configuration. * - * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitly( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitly>; updateOAuth2Bitly( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitly> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1945,15 +3216,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1979,48 +3250,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Box configuration. * - * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} */ updateOAuth2Box(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Box>; /** * Update the project OAuth2 Box configuration. * - * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Box( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Box>; updateOAuth2Box( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Box> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2030,15 +3321,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2064,48 +3355,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} */ updateOAuth2Cloudflare(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Cloudflare>; /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Cloudflare( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Cloudflare>; updateOAuth2Cloudflare( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Cloudflare> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2115,15 +3426,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2149,44 +3460,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} */ updateOAuth2Dailymotion(params?: { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dailymotion>; /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dailymotion( - apiKey?: string, - apiSecret?: string, - enabled?: boolean, + apiKey?: string | null, + apiSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dailymotion>; updateOAuth2Dailymotion( paramsOrFirst?: - { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dailymotion> { - let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + let params: { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2195,15 +3531,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - apiKey: paramsOrFirst as string, - apiSecret: rest[0] as string, - enabled: rest[1] as boolean, + apiKey: paramsOrFirst as string | null, + apiSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2229,58 +3565,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Discord configuration. * - * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} */ updateOAuth2Discord(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }): Promise<Models.OAuth2Discord>; /** * Update the project OAuth2 Discord configuration. * - * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Discord( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2DiscordPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2DiscordPrompt[] | null, ): Promise<Models.OAuth2Discord>; updateOAuth2Discord( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2DiscordPrompt[] | null)?, + ] ): Promise<Models.OAuth2Discord> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; if ( @@ -2290,24 +3646,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2DiscordPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2316,12 +3672,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2330,48 +3686,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Disqus configuration. * - * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} */ updateOAuth2Disqus(params?: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Disqus>; /** * Update the project OAuth2 Disqus configuration. * - * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Disqus( - publicKey?: string, - secretKey?: string, - enabled?: boolean, + publicKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Disqus>; updateOAuth2Disqus( paramsOrFirst?: - | { publicKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Disqus> { let params: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -2381,15 +3758,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - publicKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + publicKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2415,44 +3792,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} */ updateOAuth2Dropbox(params?: { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dropbox>; /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dropbox( - appKey?: string, - appSecret?: string, - enabled?: boolean, + appKey?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dropbox>; updateOAuth2Dropbox( paramsOrFirst?: - { appKey?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dropbox> { - let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + let params: { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2461,15 +3863,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appKey: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appKey: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2495,48 +3897,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Etsy configuration. * - * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} */ updateOAuth2Etsy(params?: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Etsy>; /** * Update the project OAuth2 Etsy configuration. * - * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Etsy( - keyString?: string, - sharedSecret?: string, - enabled?: boolean, + keyString?: string | null, + sharedSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Etsy>; updateOAuth2Etsy( paramsOrFirst?: - | { keyString?: string; sharedSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Etsy> { let params: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2546,15 +3968,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - keyString: paramsOrFirst as string, - sharedSecret: rest[0] as string, - enabled: rest[1] as boolean, + keyString: paramsOrFirst as string | null, + sharedSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2580,44 +4002,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Facebook configuration. * - * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} */ updateOAuth2Facebook(params?: { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Facebook>; /** * Update the project OAuth2 Facebook configuration. * - * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Facebook( - appId?: string, - appSecret?: string, - enabled?: boolean, + appId?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Facebook>; updateOAuth2Facebook( paramsOrFirst?: - { appId?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Facebook> { - let params: { appId?: string; appSecret?: string; enabled?: boolean }; + let params: { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2626,15 +4073,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appId: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appId: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2660,48 +4107,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Figma configuration. * - * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} */ updateOAuth2Figma(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Figma>; /** * Update the project OAuth2 Figma configuration. * - * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Figma( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Figma>; updateOAuth2Figma( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Figma> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2711,15 +4178,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2745,58 +4212,74 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} */ updateOAuth2FusionAuth(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2FusionAuth>; /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2FusionAuth( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2FusionAuth>; updateOAuth2FusionAuth( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2FusionAuth> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -2806,17 +4289,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -2846,58 +4329,79 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 GitHub configuration. * - * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} */ updateOAuth2GitHub(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }): Promise<Models.OAuth2Github>; /** * Update the project OAuth2 GitHub configuration. * - * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2GitHub( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GitHubPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2GitHubPrompt[] | null, ): Promise<Models.OAuth2Github>; updateOAuth2GitHub( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2GitHubPrompt[] | null)?, + ] ): Promise<Models.OAuth2Github> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; if ( @@ -2907,24 +4411,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GitHubPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2933,12 +4437,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2947,58 +4451,75 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} */ updateOAuth2Gitlab(params?: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Gitlab>; /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Gitlab( - applicationId?: string, - secret?: string, - endpoint?: string, - enabled?: boolean, + applicationId?: string | null, + secret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Gitlab>; updateOAuth2Gitlab( paramsOrFirst?: | { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Gitlab> { let params: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -3008,17 +4529,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - applicationId: paramsOrFirst as string, - secret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + applicationId: paramsOrFirst as string | null, + secret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -3048,76 +4569,93 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Google configuration. * - * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} */ updateOAuth2Google(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Google>; /** * Update the project OAuth2 Google configuration. * - * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Google( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GooglePrompt[], - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + prompt?: ProjectOAuth2GooglePrompt[] | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Google>; updateOAuth2Google( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - ProjectOAuth2GooglePrompt[]?, - string[]?, - boolean?, - boolean?, + (string | null)?, + (ProjectOAuth2GooglePrompt[] | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Google> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -3127,29 +4665,29 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GooglePrompt[], - nativeClientIds: rest[2] as string[], - enabled: rest[3] as boolean, - nativeEnabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + prompt: rest[1] as ProjectOAuth2GooglePrompt[] | null, + enabled: rest[2] as boolean | null, + nativeClientIds: rest[3] as string[] | null, + nativeEnabled: rest[4] as boolean | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; @@ -3162,12 +4700,12 @@ export class Project { if (typeof prompt !== 'undefined') { apiPayload['prompt'] = prompt; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -3179,48 +4717,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Hugging Face configuration. * - * @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. + * @param {string | null} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} */ updateOAuth2HuggingFace(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2HuggingFace>; /** * 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. + * @param {string | null} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2HuggingFace( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2HuggingFace>; updateOAuth2HuggingFace( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2HuggingFace> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3230,15 +4791,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3264,58 +4825,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kakao configuration. * - * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} */ updateOAuth2Kakao(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }): Promise<Models.OAuth2Kakao>; /** * Update the project OAuth2 Kakao configuration. * - * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kakao( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2KakaoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2KakaoPrompt[] | null, ): Promise<Models.OAuth2Kakao>; updateOAuth2Kakao( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2KakaoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Kakao> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; if ( @@ -3325,24 +4906,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2KakaoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2KakaoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/kakao'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3351,12 +4932,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3365,64 +4946,86 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} */ updateOAuth2Keycloak(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Keycloak>; /** * Update the project OAuth2 Keycloak configuration. * - * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com - * @param {string} realmName - Keycloak realm name. For example: appwrite-realm - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Keycloak( - clientId?: string, - clientSecret?: string, - endpoint?: string, - realmName?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + realmName?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Keycloak>; updateOAuth2Keycloak( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Keycloak> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; if ( @@ -3432,19 +5035,19 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; } 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, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + realmName: rest[2] as string | null, + enabled: rest[3] as boolean | null, }; } @@ -3478,48 +5081,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kick configuration. * - * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} */ updateOAuth2Kick(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Kick>; /** * Update the project OAuth2 Kick configuration. * - * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kick( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Kick>; updateOAuth2Kick( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Kick> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3529,15 +5154,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3563,52 +5188,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} */ updateOAuth2Linkedin(params?: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Linkedin>; /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Linkedin( - clientId?: string, - primaryClientSecret?: string, - enabled?: boolean, + clientId?: string | null, + primaryClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Linkedin>; updateOAuth2Linkedin( paramsOrFirst?: | { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Linkedin> { let params: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3618,15 +5259,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + primaryClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3652,64 +5293,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} */ updateOAuth2Microsoft(params?: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }): Promise<Models.OAuth2Microsoft>; /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Microsoft( - applicationId?: string, - applicationSecret?: string, - tenant?: string, - prompt?: ProjectOAuth2MicrosoftPrompt[], - enabled?: boolean, + applicationId?: string | null, + applicationSecret?: string | null, + tenant?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2MicrosoftPrompt[] | null, ): Promise<Models.OAuth2Microsoft>; updateOAuth2Microsoft( paramsOrFirst?: | { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2MicrosoftPrompt[] | null)?, + ] ): Promise<Models.OAuth2Microsoft> { let params: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; if ( @@ -3719,27 +5381,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; } else { params = { - applicationId: paramsOrFirst as string, - applicationSecret: rest[0] as string, - tenant: rest[1] as string, - prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], - enabled: rest[3] as boolean, + applicationId: paramsOrFirst as string | null, + applicationSecret: rest[0] as string | null, + tenant: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[] | null, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3751,12 +5413,12 @@ export class Project { if (typeof tenant !== 'undefined') { apiPayload['tenant'] = tenant; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3765,52 +5427,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Notion configuration. * - * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} */ updateOAuth2Notion(params?: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Notion>; /** * Update the project OAuth2 Notion configuration. * - * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Notion( - oauthClientId?: string, - oauthClientSecret?: string, - enabled?: boolean, + oauthClientId?: string | null, + oauthClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Notion>; updateOAuth2Notion( paramsOrFirst?: | { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Notion> { let params: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3820,15 +5500,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauthClientId: paramsOrFirst as string, - oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauthClientId: paramsOrFirst as string | null, + oauthClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3854,97 +5534,113 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Oidc configuration. * - * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} */ updateOAuth2Oidc(params?: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Oidc>; /** * Update the project OAuth2 Oidc configuration. * - * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} * @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, + clientId?: string | null, + clientSecret?: string | null, + wellKnownURL?: string | null, + authorizationURL?: string | null, + tokenURL?: string | null, + userInfoURL?: string | null, + prompt?: ProjectOAuth2OidcPrompt[] | null, + maxAge?: number | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Oidc>; updateOAuth2Oidc( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - string?, - string?, - ProjectOAuth2OidcPrompt[]?, - number?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectOAuth2OidcPrompt[] | null)?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Oidc> { let params: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; if ( @@ -3954,27 +5650,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - wellKnownURL: rest[1] as string, - authorizationURL: rest[2] as string, - tokenURL: rest[3] as string, - userInfoURL: rest[4] as string, - prompt: rest[5] as ProjectOAuth2OidcPrompt[], - maxAge: rest[6] as number, - enabled: rest[7] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + wellKnownURL: rest[1] as string | null, + authorizationURL: rest[2] as string | null, + tokenURL: rest[3] as string | null, + userInfoURL: rest[4] as string | null, + prompt: rest[5] as ProjectOAuth2OidcPrompt[] | null, + maxAge: rest[6] as number | null, + enabled: rest[7] as boolean | null, }; } @@ -4024,76 +5720,97 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Okta configuration. * - * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} */ updateOAuth2Okta(params?: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }): Promise<Models.OAuth2Okta>; /** * Update the project OAuth2 Okta configuration. * - * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Okta( - clientId?: string, - clientSecret?: string, - domain?: string, - authorizationServerId?: string, - prompt?: ProjectOAuth2OktaPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + domain?: string | null, + authorizationServerId?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2OktaPrompt[] | null, ): Promise<Models.OAuth2Okta>; updateOAuth2Okta( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - ProjectOAuth2OktaPrompt[]?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2OktaPrompt[] | null)?, ] ): Promise<Models.OAuth2Okta> { let params: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; if ( @@ -4103,21 +5820,21 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - domain: rest[1] as string, - authorizationServerId: rest[2] as string, - prompt: rest[3] as ProjectOAuth2OktaPrompt[], - enabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + domain: rest[1] as string | null, + authorizationServerId: rest[2] as string | null, + enabled: rest[3] as boolean | null, + prompt: rest[4] as ProjectOAuth2OktaPrompt[] | null, }; } @@ -4125,8 +5842,8 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4141,12 +5858,12 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { apiPayload['authorizationServerId'] = authorizationServerId; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4155,48 +5872,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Paypal configuration. * - * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2Paypal(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 Paypal configuration. * - * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Paypal( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2Paypal( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4206,15 +5946,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4240,48 +5980,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2PaypalSandbox(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2PaypalSandbox( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2PaypalSandbox( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4291,15 +6051,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4325,48 +6085,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Podio configuration. * - * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} */ updateOAuth2Podio(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Podio>; /** * Update the project OAuth2 Podio configuration. * - * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Podio( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Podio>; updateOAuth2Podio( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Podio> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4376,15 +6156,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4410,48 +6190,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Resend configuration. * - * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} */ updateOAuth2Resend(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Resend>; /** * Update the project OAuth2 Resend configuration. * - * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Resend( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Resend>; updateOAuth2Resend( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Resend> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4461,15 +6261,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4495,58 +6295,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} */ updateOAuth2Salesforce(params?: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }): Promise<Models.OAuth2Salesforce>; /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Salesforce( - customerKey?: string, - customerSecret?: string, - prompt?: ProjectOAuth2SalesforcePrompt[], - enabled?: boolean, + customerKey?: string | null, + customerSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2SalesforcePrompt[] | null, ): Promise<Models.OAuth2Salesforce>; updateOAuth2Salesforce( paramsOrFirst?: | { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2SalesforcePrompt[] | null)?, + ] ): Promise<Models.OAuth2Salesforce> { let params: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; if ( @@ -4556,24 +6376,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; } else { params = { - customerKey: paramsOrFirst as string, - customerSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], - enabled: rest[2] as boolean, + customerKey: paramsOrFirst as string | null, + customerSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[] | null, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4582,12 +6402,12 @@ export class Project { if (typeof customerSecret !== 'undefined') { apiPayload['customerSecret'] = customerSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4596,48 +6416,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Slack configuration. * - * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} */ updateOAuth2Slack(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Slack>; /** * Update the project OAuth2 Slack configuration. * - * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Slack( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Slack>; updateOAuth2Slack( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Slack> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4647,15 +6488,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4681,48 +6522,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Spotify configuration. * - * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} */ updateOAuth2Spotify(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Spotify>; /** * Update the project OAuth2 Spotify configuration. * - * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Spotify( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Spotify>; updateOAuth2Spotify( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Spotify> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4732,15 +6593,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4766,48 +6627,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Stripe configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} */ updateOAuth2Stripe(params?: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Stripe>; /** * Update the project OAuth2 Stripe configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Stripe( - clientId?: string, - apiSecretKey?: string, - enabled?: boolean, + clientId?: string | null, + apiSecretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Stripe>; updateOAuth2Stripe( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Stripe> { let params: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4817,15 +6698,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + apiSecretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4851,48 +6732,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} */ updateOAuth2TikTok(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2TikTok>; /** * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TikTok( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2TikTok>; updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2TikTok> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4902,15 +6803,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4936,52 +6837,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2Tradeshift(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Tradeshift( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2Tradeshift( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4991,15 +6908,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5025,52 +6942,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2TradeshiftSandbox(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TradeshiftSandbox( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2TradeshiftSandbox( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5080,15 +7013,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5114,48 +7047,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Twitch configuration. * - * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} */ updateOAuth2Twitch(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Twitch>; /** * Update the project OAuth2 Twitch configuration. * - * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Twitch( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Twitch>; updateOAuth2Twitch( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Twitch> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5165,15 +7118,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5199,48 +7152,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Webflow configuration. * - * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} */ updateOAuth2Webflow(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Webflow>; /** * Update the project OAuth2 Webflow configuration. * - * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Webflow( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Webflow>; updateOAuth2Webflow( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Webflow> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5250,15 +7223,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5284,48 +7257,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 WordPress configuration. * - * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} */ updateOAuth2WordPress(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2WordPress>; /** * Update the project OAuth2 WordPress configuration. * - * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2WordPress( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2WordPress>; updateOAuth2WordPress( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2WordPress> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5335,15 +7328,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5369,48 +7362,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 X configuration. * - * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} */ updateOAuth2X(params?: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2X>; /** * Update the project OAuth2 X configuration. * - * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2X( - customerKey?: string, - secretKey?: string, - enabled?: boolean, + customerKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2X>; updateOAuth2X( paramsOrFirst?: - | { customerKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2X> { let params: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -5420,15 +7433,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - customerKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + customerKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5454,48 +7467,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} */ updateOAuth2Yahoo(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yahoo>; /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yahoo( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yahoo>; updateOAuth2Yahoo( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yahoo> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5505,15 +7538,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5539,48 +7572,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yandex configuration. * - * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} */ updateOAuth2Yandex(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yandex>; /** * Update the project OAuth2 Yandex configuration. * - * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yandex( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yandex>; updateOAuth2Yandex( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yandex> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5590,15 +7643,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5624,58 +7677,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoho configuration. * - * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} */ updateOAuth2Zoho(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }): Promise<Models.OAuth2Zoho>; /** * Update the project OAuth2 Zoho configuration. * - * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoho( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2ZohoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2ZohoPrompt[] | null, ): Promise<Models.OAuth2Zoho>; updateOAuth2Zoho( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2ZohoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Zoho> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; if ( @@ -5685,24 +7758,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2ZohoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5711,12 +7784,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5725,48 +7798,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoom configuration. * - * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} */ updateOAuth2Zoom(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Zoom>; /** * Update the project OAuth2 Zoom configuration. * - * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoom( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Zoom>; updateOAuth2Zoom( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Zoom> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5776,15 +7870,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5810,7 +7904,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +8191,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + platforms: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +8213,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6098,6 +8221,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise<Models.PlatformAndroid>; /** * 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. @@ -6105,6 +8229,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +8238,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise<Models.PlatformAndroid>; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +8267,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +8306,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +8317,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6191,13 +8351,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }): Promise<Models.PlatformAndroid>; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +8368,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[] | null, ): Promise<Models.PlatformAndroid>; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + }; if ( paramsOrFirst && @@ -6224,18 +8397,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[] | null, }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +8436,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +8447,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +8561,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +8674,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +8782,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +8890,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8998,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +9106,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +9223,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +9340,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +9557,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + policies: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +9628,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +9760,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +9892,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +10024,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +10223,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +10398,209 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise<Models.Project>; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise<Models.Project>; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise<Models.Project> { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +10658,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7757,38 +10740,38 @@ export class Project { * * 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. + * @param {number | null} 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<Models.Project>} */ updatePasswordHistoryPolicy(params: { - total?: number; + total?: number | null; }): Promise<Models.Project>; /** * 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. + * @param {number | null} 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<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy(total?: number | null): Promise<Models.Project>; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -7809,7 +10792,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +10924,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +11079,224 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise<Models.Project>; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise<Models.Project>; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise<Models.Project> { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +11409,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +11484,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +11616,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +11748,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,40 +11878,116 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ - updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + updateUserLimitPolicy(params: { + total?: number | null; + }): Promise<Models.Project>; /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy(total?: number | null): Promise<Models.Project>; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -8345,15 +12008,89 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +12100,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +12112,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +12130,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +12142,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +12152,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +12164,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +12280,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,104 +12435,179 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * - * @param {string} params.host - SMTP server hostname (domain) - * @param {number} params.port - SMTP server port - * @param {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} params.host - SMTP server hostname (domain) + * @param {number | null} params.port - SMTP server port + * @param {string | null} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ updateSMTP(params?: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }): Promise<Models.Project>; /** * 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. * - * @param {string} host - SMTP server hostname (domain) - * @param {number} port - SMTP server port - * @param {string} username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} host - SMTP server hostname (domain) + * @param {number | null} port - SMTP server port + * @param {string | null} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @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, + host?: string | null, + port?: number | null, + username?: string | null, + password?: string | null, + senderEmail?: string | null, + senderName?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, + secure?: ProjectSMTPSecure | null, + enabled?: boolean | null, ): Promise<Models.Project>; updateSMTP( paramsOrFirst?: | { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - number?, - string?, - string?, - string?, - string?, - string?, - string?, - ProjectSMTPSecure?, - boolean?, + (number | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectSMTPSecure | null)?, + (boolean | null)?, ] ): Promise<Models.Project> { let params: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; if ( @@ -8725,29 +12617,29 @@ export class Project { !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; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; } else { params = { - host: paramsOrFirst as string, - port: rest[0] as number, - username: rest[1] as string, - password: rest[2] as string, - senderEmail: rest[3] as string, - senderName: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, - secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean, + host: paramsOrFirst as string | null, + port: rest[0] as number | null, + username: rest[1] as string | null, + password: rest[2] as string | null, + senderEmail: rest[3] as string | null, + senderName: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, + secure: rest[7] as ProjectSMTPSecure | null, + enabled: rest[8] as boolean | null, }; } @@ -8801,7 +12693,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: [], + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +12889,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + templates: [], + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8931,36 +12927,36 @@ export class Project { * * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. - * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} params.senderName - Name of the email sender. - * @param {string} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Reply to name. + * @param {string | null} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} params.senderName - Name of the email sender. + * @param {string | null} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} */ updateEmailTemplate(params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.EmailTemplate>; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} subject - Subject of the email template. Can be up to 255 characters. - * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} senderName - Name of the email sender. - * @param {string} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Reply to name. + * @param {string | null} subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} senderName - Name of the email sender. + * @param {string | null} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8968,45 +12964,45 @@ export class Project { updateEmailTemplate( templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, - subject?: string, - message?: string, - senderName?: string, - senderEmail?: string, - replyToEmail?: string, - replyToName?: string, + subject?: string | null, + message?: string | null, + senderName?: string | null, + senderEmail?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.EmailTemplate>; updateEmailTemplate( paramsOrFirst: | { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; } | ProjectEmailTemplateId, ...rest: [ ProjectEmailTemplateLocale?, - string?, - string?, - string?, - string?, - string?, - string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.EmailTemplate> { let params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -9025,23 +13021,23 @@ export class Project { params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, locale: rest[0] as ProjectEmailTemplateLocale, - subject: rest[1] as string, - message: rest[2] as string, - senderName: rest[3] as string, - senderEmail: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, + subject: rest[1] as string | null, + message: rest[2] as string | null, + senderName: rest[3] as string | null, + senderEmail: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, }; } @@ -9092,7 +13088,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +13188,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +13275,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +13416,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,58 +13490,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ updateVariable( variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.Variable> { let params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -9468,16 +13570,16 @@ export class Project { ) { params = (paramsOrFirst || {}) as { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } else { params = { variableId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean, + key: rest[0] as string | null, + value: rest[1] as string | null, + secret: rest[2] as boolean | null, }; } @@ -9512,7 +13614,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..4a9bded 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,7 +111,22 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +194,42 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + rules: [], + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +287,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +402,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +563,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +676,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +753,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +883,30 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2424cc0 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,79 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + sites: [], + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +550,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +662,47 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + frameworks: [], + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + runtimes: [], + adapters: [], + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +770,33 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +847,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -667,16 +928,16 @@ export class Sites { * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} */ @@ -695,16 +956,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }): Promise<Models.Site>; /** * Update site by its unique ID. @@ -723,16 +984,16 @@ export class Sites { * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} * @deprecated Use the object parameter style method for a better developer experience. @@ -752,16 +1013,16 @@ export class Sites { adapter?: Adapter, fallbackFile?: string, installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, runtimeSpecification?: string, deploymentRetention?: number, - scopes?: ProjectKeyScopes[], + scopes?: ProjectKeyScopes[] | null, ): Promise<Models.Site>; update( paramsOrFirst: @@ -780,16 +1041,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; } | string, ...rest: [ @@ -806,16 +1067,16 @@ export class Sites { Adapter?, string?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, string?, number?, - ProjectKeyScopes[]?, + (ProjectKeyScopes[] | null)?, ] ): Promise<Models.Site> { let params: { @@ -833,16 +1094,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; if ( @@ -865,16 +1126,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; } else { params = { @@ -892,16 +1153,16 @@ export class Sites { adapter: rest[10] as Adapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, - providerRepositoryId: rest[13] as string, + providerRepositoryId: rest[13] as string | null, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - providerBranches: rest[17] as string[], - providerPaths: rest[18] as string[], - buildSpecification: rest[19] as string, + providerBranches: rest[17] as string[] | null, + providerPaths: rest[18] as string[] | null, + buildSpecification: rest[19] as string | null, runtimeSpecification: rest[20] as string, deploymentRetention: rest[21] as number, - scopes: rest[22] as ProjectKeyScopes[], + scopes: rest[22] as ProjectKeyScopes[] | null, }; } @@ -1022,7 +1283,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1472,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1635,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1910,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2118,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2270,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2381,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2677,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2795,59 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2910,48 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3093,37 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3249,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3336,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2586,27 +3363,27 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2614,28 +3391,33 @@ export class Sites { updateVariable( siteId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2646,17 +3428,17 @@ export class Sites { params = (paramsOrFirst || {}) as { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2694,7 +3476,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..d810652 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,43 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + buckets: [], + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -101,7 +138,7 @@ export class Storage { * * @param {string} params.bucketId - 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 - Bucket name - * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -116,7 +153,7 @@ export class Storage { createBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -131,7 +168,7 @@ export class Storage { * * @param {string} bucketId - 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 - Bucket name - * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -147,7 +184,7 @@ export class Storage { createBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, @@ -162,7 +199,7 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -175,7 +212,7 @@ export class Storage { | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, number?, @@ -189,7 +226,7 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -208,7 +245,7 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -222,7 +259,7 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, maximumFileSize: rest[4] as number, @@ -296,7 +333,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +413,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,13 +446,13 @@ export class Storage { * * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.name - Bucket name - * @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 {string[] | null} 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.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -374,13 +461,13 @@ export class Storage { updateBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }): Promise<Models.Bucket>; @@ -389,13 +476,13 @@ export class Storage { * * @param {string} bucketId - Bucket unique ID. * @param {string} name - Bucket name - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -405,13 +492,13 @@ export class Storage { updateBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, - maximumFileSize?: number, + maximumFileSize?: number | null, allowedFileExtensions?: string[], - compression?: Compression, - encryption?: boolean, + compression?: Compression | null, + encryption?: boolean | null, antivirus?: boolean, transformations?: boolean, ): Promise<Models.Bucket>; @@ -420,26 +507,26 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; } | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, - number?, + (number | null)?, string[]?, - Compression?, - boolean?, + (Compression | null)?, + (boolean | null)?, boolean?, boolean?, ] @@ -447,13 +534,13 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -466,13 +553,13 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -480,13 +567,13 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, - maximumFileSize: rest[4] as number, + maximumFileSize: rest[4] as number | null, allowedFileExtensions: rest[5] as string[], - compression: rest[6] as Compression, - encryption: rest[7] as boolean, + compression: rest[6] as Compression | null, + encryption: rest[7] as boolean | null, antivirus: rest[8] as boolean, transformations: rest[9] as boolean, }; @@ -554,7 +641,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +824,45 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + files: [], + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1084,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -943,7 +1120,7 @@ export class Storage { * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.fileId - File ID. * @param {string} params.name - File name. - * @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 {string[] | null} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ @@ -951,7 +1128,7 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }): Promise<Models.File>; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -959,7 +1136,7 @@ export class Storage { * @param {string} bucketId - Bucket unique ID. * @param {string} fileId - File ID. * @param {string} name - File name. - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} * @deprecated Use the object parameter style method for a better developer experience. @@ -968,7 +1145,7 @@ export class Storage { bucketId: string, fileId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, ): Promise<Models.File>; updateFile( paramsOrFirst: @@ -976,16 +1153,16 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.File> { let params: { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; if ( @@ -997,14 +1174,14 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; } 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[] | null, }; } @@ -1038,7 +1215,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..795ed7d 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,69 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,7 +167,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -110,7 +177,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -121,7 +188,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -132,7 +199,7 @@ export class TablesDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -142,10 +209,10 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -153,7 +220,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -167,7 +234,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -176,7 +243,7 @@ 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 | null, }; } @@ -222,7 +289,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +359,42 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +462,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +542,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +616,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +722,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +870,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +942,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,9 +1002,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -712,9 +1012,9 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -722,9 +1022,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -733,9 +1033,9 @@ export class TablesDB { databaseId: string, name?: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -743,20 +1043,26 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -768,18 +1074,18 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -822,7 +1128,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,33 +1240,33 @@ export class TablesDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -918,12 +1275,12 @@ export class TablesDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -950,7 +1307,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,7 +1420,46 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + migrations: [], + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1105,7 +1557,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1658,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1327,7 +1835,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1967,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2054,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2138,52 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2287,59 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + tables: [], + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1656,11 +2348,11 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - 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 - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} params.columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} */ @@ -1668,7 +2360,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1680,11 +2372,11 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - 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 - Table 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 {string[] | null} 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} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1693,7 +2385,7 @@ export class TablesDB { databaseId: string, tableId: string, name: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, columns?: object[], @@ -1705,7 +2397,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1715,7 +2407,7 @@ export class TablesDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1726,7 +2418,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1742,7 +2434,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1753,7 +2445,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], @@ -1816,7 +2508,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2619,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1895,7 +2669,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.name - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1906,7 +2680,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1917,7 +2691,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} name - Table 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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1929,7 +2703,7 @@ export class TablesDB { databaseId: string, tableId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1940,19 +2714,26 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Table> { let params: { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1967,7 +2748,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1977,7 +2758,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -2028,7 +2809,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +3023,20 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + columns: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2212,9 +3047,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2224,9 +3059,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnBigint>; /** @@ -2237,9 +3072,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2250,9 +3085,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnBigint>; createBigIntColumn( @@ -2262,9 +3097,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -2272,9 +3107,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnBigint> { @@ -2283,9 +3118,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -2299,9 +3134,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -2310,9 +3145,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -2373,7 +3208,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,10 +3236,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} */ @@ -2396,10 +3248,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnBigint>; /** * Update a bigint column. Changing the `default` value will not update already existing rows. @@ -2409,10 +3261,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2422,10 +3274,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnBigint>; updateBigIntColumn( paramsOrFirst: @@ -2434,20 +3286,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnBigint> { let params: { @@ -2455,10 +3307,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -2471,10 +3323,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -2482,10 +3334,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -2549,7 +3401,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2560,7 +3429,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2570,7 +3439,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.ColumnBoolean>; /** @@ -2581,7 +3450,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2592,7 +3461,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.ColumnBoolean>; createBooleanColumn( @@ -2602,18 +3471,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -2627,7 +3496,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -2636,7 +3505,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -2690,7 +3559,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2700,8 +3586,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} */ @@ -2710,8 +3596,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.ColumnBoolean>; /** * Update a boolean column. Changing the `default` value will not update already existing rows. @@ -2720,8 +3606,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2731,8 +3617,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.ColumnBoolean>; updateBooleanColumn( paramsOrFirst: @@ -2741,19 +3627,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2766,8 +3658,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2775,8 +3667,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2832,7 +3724,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2842,7 +3751,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2852,7 +3761,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnDatetime>; /** @@ -2862,7 +3771,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2873,7 +3782,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnDatetime>; createDatetimeColumn( @@ -2883,18 +3792,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2908,7 +3817,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2917,7 +3826,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2971,7 +3880,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2981,8 +3907,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} */ @@ -2991,8 +3917,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnDatetime>; /** * Update a date time column. Changing the `default` value will not update already existing rows. @@ -3001,8 +3927,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3012,8 +3938,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnDatetime>; updateDatetimeColumn( paramsOrFirst: @@ -3022,19 +3948,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3047,8 +3979,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3056,8 +3988,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3113,7 +4045,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3124,7 +4073,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3134,7 +4083,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEmail>; /** @@ -3145,7 +4094,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3156,7 +4105,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEmail>; createEmailColumn( @@ -3166,18 +4115,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3191,7 +4140,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3200,7 +4149,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3253,7 +4202,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,8 +4231,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} */ @@ -3274,8 +4241,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEmail>; /** * Update an email column. Changing the `default` value will not update already existing rows. @@ -3285,8 +4252,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3296,8 +4263,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEmail>; updateEmailColumn( paramsOrFirst: @@ -3306,19 +4273,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3331,8 +4304,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3340,8 +4313,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3397,7 +4370,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3408,7 +4399,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3419,7 +4410,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEnum>; /** @@ -3430,7 +4421,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3442,7 +4433,7 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEnum>; createEnumColumn( @@ -3453,11 +4444,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3465,7 +4463,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3480,7 +4478,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3490,7 +4488,7 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -3552,7 +4550,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3564,8 +4581,8 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} */ @@ -3575,8 +4592,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEnum>; /** * Update an enum column. Changing the `default` value will not update already existing rows. @@ -3587,8 +4604,8 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3599,8 +4616,8 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEnum>; updateEnumColumn( paramsOrFirst: @@ -3610,11 +4627,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3622,8 +4646,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3637,8 +4661,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3647,8 +4671,8 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3713,7 +4737,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3724,9 +4767,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3736,9 +4779,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.ColumnFloat>; /** @@ -3749,9 +4792,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3762,9 +4805,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.ColumnFloat>; createFloatColumn( @@ -3774,9 +4817,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3784,9 +4827,9 @@ export class TablesDB { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.ColumnFloat> { @@ -3795,9 +4838,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3811,9 +4854,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3822,9 +4865,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3885,7 +4928,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3896,10 +4956,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} */ @@ -3908,10 +4968,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.ColumnFloat>; /** * Update a float column. Changing the `default` value will not update already existing rows. @@ -3921,10 +4981,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3934,10 +4994,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.ColumnFloat>; updateFloatColumn( paramsOrFirst: @@ -3946,20 +5006,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.ColumnFloat> { let params: { @@ -3967,10 +5027,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3983,10 +5043,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3994,10 +5054,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -4061,7 +5121,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4072,9 +5149,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4084,9 +5161,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnInteger>; /** @@ -4097,9 +5174,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4110,9 +5187,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnInteger>; createIntegerColumn( @@ -4122,9 +5199,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -4132,9 +5209,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnInteger> { @@ -4143,9 +5220,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -4159,9 +5236,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -4170,9 +5247,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -4234,7 +5311,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4245,10 +5339,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} */ @@ -4257,10 +5351,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnInteger>; /** * Update an integer column. Changing the `default` value will not update already existing rows. @@ -4270,10 +5364,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4283,10 +5377,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnInteger>; updateIntegerColumn( paramsOrFirst: @@ -4295,20 +5389,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnInteger> { let params: { @@ -4316,10 +5410,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -4332,10 +5426,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -4343,10 +5437,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -4410,7 +5504,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4421,7 +5532,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4431,7 +5542,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnIp>; /** @@ -4442,7 +5553,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4453,7 +5564,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnIp>; createIpColumn( @@ -4463,18 +5574,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -4488,7 +5599,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -4497,7 +5608,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -4550,7 +5661,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4561,8 +5690,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} */ @@ -4571,8 +5700,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnIp>; /** * Update an ip column. Changing the `default` value will not update already existing rows. @@ -4582,8 +5711,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4593,8 +5722,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnIp>; updateIpColumn( paramsOrFirst: @@ -4603,19 +5732,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4628,8 +5763,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4637,8 +5772,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4694,7 +5829,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4704,7 +5857,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4713,7 +5866,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnLine>; /** * Create a geometric line column. @@ -4722,7 +5875,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4732,7 +5885,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnLine>; createLineColumn( paramsOrFirst: @@ -4741,17 +5894,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4764,7 +5917,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4772,7 +5925,7 @@ export class TablesDB { 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[][] | null, }; } @@ -4820,7 +5973,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4830,8 +6000,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4840,8 +6010,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnLine>; /** * Update a line column. Changing the `default` value will not update already existing rows. @@ -4850,8 +6020,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4861,8 +6031,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnLine>; updateLineColumn( paramsOrFirst: @@ -4871,19 +6041,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4896,8 +6072,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4905,8 +6081,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4957,7 +6133,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4968,7 +6161,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -4979,7 +6172,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnLongtext>; @@ -4991,7 +6184,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5003,7 +6196,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnLongtext>; @@ -5014,19 +6207,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5041,7 +6241,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5051,7 +6251,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5110,7 +6310,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5121,8 +6338,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} */ @@ -5131,8 +6348,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnLongtext>; /** * Update a longtext column. Changing the `default` value will not update already existing rows. @@ -5142,8 +6359,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5153,8 +6370,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnLongtext>; updateLongtextColumn( paramsOrFirst: @@ -5163,19 +6380,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5188,8 +6411,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5197,8 +6420,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5254,7 +6477,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5265,7 +6505,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5276,7 +6516,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnMediumtext>; @@ -5288,7 +6528,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5300,7 +6540,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnMediumtext>; @@ -5311,19 +6551,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5338,7 +6585,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5348,7 +6595,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5407,7 +6654,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5418,8 +6682,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} */ @@ -5428,8 +6692,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnMediumtext>; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -5439,8 +6703,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5450,8 +6714,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnMediumtext>; updateMediumtextColumn( paramsOrFirst: @@ -5460,19 +6724,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5485,8 +6755,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5494,8 +6764,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5551,7 +6821,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5561,7 +6848,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5570,7 +6857,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.ColumnPoint>; /** * Create a geometric point column. @@ -5579,7 +6866,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5589,7 +6876,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.ColumnPoint>; createPointColumn( paramsOrFirst: @@ -5598,17 +6885,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -5621,7 +6908,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -5629,7 +6916,7 @@ export class TablesDB { 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[] | null, }; } @@ -5677,7 +6964,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5687,8 +6991,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5697,8 +7001,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.ColumnPoint>; /** * Update a point column. Changing the `default` value will not update already existing rows. @@ -5707,8 +7011,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5718,8 +7022,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.ColumnPoint>; updatePointColumn( paramsOrFirst: @@ -5728,19 +7032,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5753,8 +7063,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5762,8 +7072,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5814,7 +7124,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5824,7 +7151,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5833,7 +7160,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnPolygon>; /** * Create a geometric polygon column. @@ -5842,7 +7169,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5852,7 +7179,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnPolygon>; createPolygonColumn( paramsOrFirst: @@ -5861,17 +7188,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5884,7 +7211,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5892,7 +7219,7 @@ export class TablesDB { 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[][] | null, }; } @@ -5941,7 +7268,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5951,8 +7295,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5961,8 +7305,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnPolygon>; /** * Update a polygon column. Changing the `default` value will not update already existing rows. @@ -5971,8 +7315,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5982,8 +7326,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnPolygon>; updatePolygonColumn( paramsOrFirst: @@ -5992,19 +7336,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -6017,8 +7367,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -6026,8 +7376,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -6078,7 +7428,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6090,8 +7457,8 @@ export class TablesDB { * @param {string} params.relatedTableId - Related Table ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Column Key. - * @param {string} params.twoWayKey - Two Way Column Key. + * @param {string | null} params.key - Column Key. + * @param {string | null} params.twoWayKey - Two Way Column Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6102,8 +7469,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.ColumnRelationship>; /** @@ -6115,8 +7482,8 @@ export class TablesDB { * @param {string} relatedTableId - Related Table ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Column Key. - * @param {string} twoWayKey - Two Way Column Key. + * @param {string | null} key - Column Key. + * @param {string | null} twoWayKey - Two Way Column Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6128,8 +7495,8 @@ export class TablesDB { relatedTableId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.ColumnRelationship>; createRelationshipColumn( @@ -6140,8 +7507,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -6150,8 +7517,8 @@ export class TablesDB { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.ColumnRelationship> { @@ -6161,8 +7528,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -6177,8 +7544,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -6188,8 +7555,8 @@ export class TablesDB { relatedTableId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -6251,7 +7618,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6261,8 +7650,8 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. + * @param {RelationMutate | null} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} */ @@ -6270,8 +7659,8 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }): Promise<Models.ColumnRelationship>; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -6280,8 +7669,8 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. + * @param {RelationMutate | null} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6290,8 +7679,8 @@ export class TablesDB { databaseId: string, tableId: string, key: string, - onDelete?: RelationMutate, - newKey?: string, + onDelete?: RelationMutate | null, + newKey?: string | null, ): Promise<Models.ColumnRelationship>; updateRelationshipColumn( paramsOrFirst: @@ -6299,18 +7688,18 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, (RelationMutate | null)?, (string | null)?] ): Promise<Models.ColumnRelationship> { let params: { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; if ( @@ -6322,16 +7711,16 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; } 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, + onDelete: rest[2] as RelationMutate | null, + newKey: rest[3] as string | null, }; } @@ -6373,7 +7762,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6385,7 +7796,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6398,7 +7809,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnString>; @@ -6411,7 +7822,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6424,7 +7835,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnString>; @@ -6436,7 +7847,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6446,7 +7857,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6457,7 +7868,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6473,7 +7884,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6484,7 +7895,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6549,7 +7960,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6560,9 +7989,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the string column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the string column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6572,9 +8001,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnString>; /** * Update a string column. Changing the `default` value will not update already existing rows. @@ -6584,9 +8013,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the string column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the string column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6596,9 +8025,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnString>; updateStringColumn( paramsOrFirst: @@ -6607,21 +8036,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnString> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6634,9 +8070,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6644,9 +8080,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6706,7 +8142,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6717,7 +8171,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6728,7 +8182,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnText>; @@ -6740,7 +8194,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6752,7 +8206,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnText>; @@ -6763,19 +8217,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6790,7 +8251,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6800,7 +8261,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6858,7 +8319,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6869,8 +8347,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} */ @@ -6879,8 +8357,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnText>; /** * Update a text column. Changing the `default` value will not update already existing rows. @@ -6890,8 +8368,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6901,8 +8379,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnText>; updateTextColumn( paramsOrFirst: @@ -6911,19 +8389,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6936,8 +8420,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6945,8 +8429,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7002,7 +8486,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7013,7 +8514,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7023,7 +8524,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnUrl>; /** @@ -7034,7 +8535,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7045,7 +8546,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnUrl>; createUrlColumn( @@ -7055,18 +8556,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -7080,7 +8581,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -7089,7 +8590,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -7142,7 +8643,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7153,8 +8672,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} */ @@ -7163,8 +8682,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnUrl>; /** * Update an url column. Changing the `default` value will not update already existing rows. @@ -7174,8 +8693,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7185,8 +8704,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnUrl>; updateUrlColumn( paramsOrFirst: @@ -7195,19 +8714,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -7220,8 +8745,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -7229,8 +8754,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7286,7 +8811,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7298,7 +8841,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7310,7 +8853,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnVarchar>; @@ -7323,7 +8866,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7336,7 +8879,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnVarchar>; @@ -7348,7 +8891,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -7358,7 +8901,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -7369,7 +8912,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7385,7 +8928,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7396,7 +8939,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -7462,7 +9005,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7473,9 +9034,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the varchar column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the varchar column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} */ @@ -7484,9 +9045,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnVarchar>; /** * Update a varchar column. Changing the `default` value will not update already existing rows. @@ -7496,9 +9057,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the varchar column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the varchar column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7508,9 +9069,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnVarchar>; updateVarcharColumn( paramsOrFirst: @@ -7519,21 +9080,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnVarchar> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -7546,9 +9114,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -7556,9 +9124,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7618,7 +9186,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,12 +9533,43 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -7975,7 +9592,7 @@ export class TablesDB { }): Promise<Models.ColumnIndex>; /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -8109,7 +9726,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9831,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +10062,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8415,8 +10101,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -8427,8 +10113,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -8437,8 +10123,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8450,8 +10136,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8462,8 +10148,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8472,8 +10158,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -8483,8 +10169,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8499,8 +10185,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8510,8 +10196,8 @@ export class TablesDB { data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8561,7 +10247,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8570,7 +10274,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} params.rows - Array of rows data as JSON objects. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8578,7 +10282,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8586,7 +10290,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} rows - Array of rows data as JSON objects. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8595,7 +10299,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; createRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8603,16 +10307,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8624,14 +10328,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8670,7 +10374,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8680,7 +10413,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8688,7 +10421,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8697,7 +10430,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8706,7 +10439,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; upsertRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8714,16 +10447,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8735,14 +10468,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8781,7 +10514,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8791,7 +10553,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column 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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8800,7 +10562,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8809,7 +10571,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column 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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8819,7 +10581,7 @@ export class TablesDB { tableId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; updateRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8828,17 +10590,17 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8851,7 +10613,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -8859,7 +10621,7 @@ export class TablesDB { 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 | null, }; } @@ -8899,7 +10661,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10796,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10943,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9133,8 +10971,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9145,8 +10983,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -9155,8 +10993,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9168,8 +11006,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; upsertRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9181,8 +11019,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9191,8 +11029,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9202,8 +11040,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9219,8 +11057,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9231,8 +11069,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9277,7 +11115,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9287,8 +11143,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9299,8 +11155,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -9309,8 +11165,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9322,8 +11178,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; updateRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9335,8 +11191,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9345,8 +11201,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9356,8 +11212,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9373,8 +11229,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9385,8 +11241,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9431,7 +11287,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9549,8 +11423,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9560,8 +11434,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Decrement a specific column of a row by a given value. @@ -9571,8 +11445,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9583,8 +11457,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Row>; decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9594,11 +11468,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9606,8 +11487,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -9621,8 +11502,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9631,8 +11512,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9683,7 +11564,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9694,8 +11593,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9705,8 +11604,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Increment a specific column of a row by a given value. @@ -9716,8 +11615,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9728,8 +11627,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Row>; incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9739,11 +11638,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9751,8 +11657,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -9766,8 +11672,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9776,8 +11682,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9828,6 +11734,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..8e9f2ae 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,34 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + teams: [], + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +205,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +278,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +368,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +517,38 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +638,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +732,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,21 +760,21 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} teamId - Team ID. * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. @@ -631,22 +782,22 @@ export class Teams { updateInstallation( teamId: string, installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: | { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.AppInstallation> { let params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; if ( @@ -657,13 +808,13 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string, + authorizationDetails: rest[1] as string | null, }; } @@ -696,7 +847,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1041,44 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -890,6 +1098,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} */ @@ -901,6 +1110,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise<Models.Membership>; /** * 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. @@ -919,6 +1129,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} * @deprecated Use the object parameter style method for a better developer experience. @@ -931,6 +1142,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise<Models.Membership>; createMembership( paramsOrFirst: @@ -942,9 +1154,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise<Models.Membership> { let params: { teamId: string; @@ -954,6 +1175,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -969,6 +1191,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -979,6 +1202,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -989,6 +1213,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1018,6 +1243,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1026,7 +1254,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1354,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1471,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1688,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..580a3d4 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,36 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -116,21 +150,21 @@ export class Tokens { * * @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 unique ID. - * @param {string} params.expire - Token expiry date + * @param {string | null} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ createFileToken(params: { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * * @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 unique ID. - * @param {string} expire - Token expiry date + * @param {string | null} expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. @@ -138,14 +172,19 @@ export class Tokens { createFileToken( bucketId: string, fileId: string, - expire?: string, + expire?: string | null, ): Promise<Models.ResourceToken>; createFileToken( paramsOrFirst: - { bucketId: string; fileId: string; expire?: string } | string, - ...rest: [string?, string?] + | { bucketId: string; fileId: string; expire?: string | null } + | string, + ...rest: [string?, (string | null)?] ): Promise<Models.ResourceToken> { - let params: { bucketId: string; fileId: string; expire?: string }; + let params: { + bucketId: string; + fileId: string; + expire?: string | null; + }; if ( paramsOrFirst && @@ -155,13 +194,13 @@ export class Tokens { params = (paramsOrFirst || {}) as { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string, + expire: rest[1] as string | null, }; } @@ -191,7 +230,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,36 +303,57 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} params.tokenId - Token unique ID. - * @param {string} params.expire - File token expiry date + * @param {string | null} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ update(params: { tokenId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} tokenId - Token unique ID. - * @param {string} expire - File token expiry date + * @param {string | null} expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; update( - paramsOrFirst: { tokenId: string; expire?: string } | string, - ...rest: [string?] + tokenId: string, + expire?: string | null, + ): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string; expire?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.ResourceToken> { - let params: { tokenId: string; expire?: string }; + let params: { tokenId: string; expire?: string | null }; if ( paramsOrFirst && @@ -284,12 +362,12 @@ export class Tokens { ) { params = (paramsOrFirst || {}) as { tokenId: string; - expire?: string; + expire?: string | null; }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string, + expire: rest[0] as string | null, }; } @@ -316,7 +394,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..77a515b 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,16 +94,70 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + users: [], + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new user. * * @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. - * @param {string} params.email - User email. - * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string | null} params.email - User email. + * @param {string | null} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} params.password - Plain text user password. Must be at least 8 chars. * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -107,18 +166,18 @@ export class Users { Preferences extends Models.Preferences = Models.DefaultPreferences, >(params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }): Promise<Models.User<Preferences>>; /** * Create a new user. * * @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. - * @param {string} email - User email. - * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string | null} email - User email. + * @param {string | null} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} password - Plain text user password. Must be at least 8 chars. * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -126,28 +185,28 @@ export class Users { */ create<Preferences extends Models.Preferences = Models.DefaultPreferences>( userId: string, - email?: string, - phone?: string, - password?: string, + email?: string | null, + phone?: string | null, + password?: string | null, name?: string, ): Promise<Models.User<Preferences>>; create<Preferences extends Models.Preferences = Models.DefaultPreferences>( paramsOrFirst: | { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [(string | null)?, (string | null)?, (string | null)?, string?] ): Promise<Models.User<Preferences>> { let params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; @@ -158,17 +217,17 @@ export class Users { ) { params = (paramsOrFirst || {}) as { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string, - phone: rest[1] as string, - password: rest[2] as string, + email: rest[0] as string | null, + phone: rest[1] as string | null, + password: rest[2] as string | null, name: rest[3] as string, }; } @@ -206,7 +265,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +420,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +575,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +697,40 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +898,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1053,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1307,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1518,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1690,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1790,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1959,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2083,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2301,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2446,44 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2558,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2675,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2930,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +3000,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3069,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3141,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3277,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3345,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3414,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3482,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3568,410 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise<Models.PasskeyList> { + 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, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise<Models.Passkey>; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4050,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4170,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4408,58 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4517,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4752,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4876,37 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5048,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5135,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5270,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5439,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5538,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5663,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..d2f0c5d 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,69 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class VectorsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class VectorsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class VectorsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,59 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1530,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1647,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1209,7 +1700,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} */ @@ -1220,7 +1711,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.VectorsdbCollection>; /** * Update a collection by its unique ID. @@ -1231,7 +1722,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1243,7 +1734,7 @@ export class VectorsDB { dimension?: number, permissions?: string[], documentSecurity?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.VectorsdbCollection>; updateCollection( paramsOrFirst: @@ -1254,10 +1745,17 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ...rest: [ + string?, + string?, + number?, + string[]?, + boolean?, + (boolean | null)?, + ] ): Promise<Models.VectorsdbCollection> { let params: { databaseId: string; @@ -1266,7 +1764,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -1281,7 +1779,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -1291,7 +1789,7 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean, + enabled: rest[5] as boolean | null, }; } @@ -1345,7 +1843,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2093,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2291,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2426,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2574,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2727,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2868,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +3035,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3193,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3380,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3567,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3810,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +4006,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4114,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3377,33 +4230,33 @@ export class VectorsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3412,12 +4265,12 @@ export class VectorsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3444,7 +4297,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4457,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4544,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4628,51 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..f5ecff3 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2415 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise<Models.WafRuleList>; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise<Models.WafRuleList>; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise<Models.WafRuleList> { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + rules: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleBypass>; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleBypass>; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleBypass>; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleBypass>; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise<Models.WafRuleChallenge>; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise<Models.WafRuleChallenge>; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.challengeType - Challenge type enforced by the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }): Promise<Models.WafRuleChallenge>; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} challengeType - Challenge type enforced by the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + challengeType?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + difficulty?: number | null, + ttl?: number | null, + ): Promise<Models.WafRuleChallenge>; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + challengeType: rest[4] as string | null, + priority: rest[5] as number | null, + enabled: rest[6] as boolean | null, + conditions: rest[7] as string[] | null, + difficulty: rest[8] as number | null, + ttl: rest[9] as number | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleDeny>; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleDeny>; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleDeny>; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleDeny>; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRateLimit>; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string | null, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number | null, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRateLimit>; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + (string | null)?, + string?, + string?, + string?, + (number | null)?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number | null, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRateLimit>; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} interval - Interval in seconds used for rate limiting. + * @param {string | null} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + limit?: number | null, + interval?: number | null, + key?: string | null, + maxBucketSize?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRateLimit>; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + limit: rest[4] as number | null, + interval: rest[5] as number | null, + key: rest[6] as string | null, + maxBucketSize: rest[7] as number | null, + priority: rest[8] as number | null, + enabled: rest[9] as boolean | null, + conditions: rest[10] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRedirect>; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRedirect>; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.location - Location used for redirect responses. + * @param {number | null} params.statusCode - Integer status code used for redirect responses. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRedirect>; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} location - Location used for redirect responses. + * @param {number | null} statusCode - Integer status code used for redirect responses. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + location?: string | null, + statusCode?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRedirect>; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + location: rest[4] as string | null, + statusCode: rest[5] as number | null, + priority: rest[6] as number | null, + enabled: rest[7] as boolean | null, + conditions: rest[8] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: [], + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..32f492f 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,42 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + webhooks: [], + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,9 +122,9 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -97,7 +137,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -108,9 +148,9 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -124,7 +164,7 @@ export class Webhooks { tls?: boolean, authUsername?: string, authPassword?: string, - secret?: string, + secret?: string | null, ): Promise<Models.Webhook>; create( paramsOrFirst: @@ -137,7 +177,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; } | string, ...rest: [ @@ -148,7 +188,7 @@ export class Webhooks { boolean?, string?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -160,7 +200,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; if ( @@ -177,7 +217,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; } else { params = { @@ -189,7 +229,7 @@ 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 | null, }; } @@ -253,7 +293,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +372,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +408,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -333,7 +421,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }): Promise<Models.Webhook>; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -344,8 +432,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -358,7 +446,7 @@ export class Webhooks { enabled?: boolean, tls?: boolean, authUsername?: string, - authPassword?: string, + authPassword?: string | null, ): Promise<Models.Webhook>; update( paramsOrFirst: @@ -370,7 +458,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; } | string, ...rest: [ @@ -380,7 +468,7 @@ export class Webhooks { boolean?, boolean?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -391,7 +479,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; if ( @@ -407,7 +495,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; } else { params = { @@ -418,7 +506,7 @@ 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 | null, }; } @@ -478,7 +566,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -539,29 +651,32 @@ export class Webhooks { * 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. * * @param {string} params.webhookId - Webhook ID. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ updateSecret(params: { webhookId: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * 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. * * @param {string} webhookId - Webhook ID. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; updateSecret( - paramsOrFirst: { webhookId: string; secret?: string } | string, - ...rest: [string?] + webhookId: string, + secret?: string | null, + ): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string; secret?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.Webhook> { - let params: { webhookId: string; secret?: string }; + let params: { webhookId: string; secret?: string | null }; if ( paramsOrFirst && @@ -570,12 +685,12 @@ export class Webhooks { ) { params = (paramsOrFirst || {}) as { webhookId: string; - secret?: string; + secret?: string | null; }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string, + secret: rest[0] as string | null, }; } @@ -602,6 +717,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..0bd3f1c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -13,9 +13,9 @@ describe('Account', () => { 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', + $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, @@ -40,9 +40,9 @@ describe('Account', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Account', () => { }); 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', + $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', @@ -129,9 +129,9 @@ describe('Account', () => { }); 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', + $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', @@ -168,9 +168,9 @@ describe('Account', () => { }); 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', + $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, @@ -221,9 +221,9 @@ describe('Account', () => { }); 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', + $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, @@ -274,9 +274,9 @@ describe('Account', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Account', () => { }); 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', + $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, @@ -348,8 +348,8 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -363,8 +363,8 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -378,9 +378,9 @@ describe('Account', () => { }); 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', + $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', @@ -421,9 +421,9 @@ describe('Account', () => { }); 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', + $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', @@ -568,9 +568,9 @@ describe('Account', () => { }); 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', + $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, @@ -593,11 +593,101 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('<PASSKEY_ID>', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '<PASSKEY_ID>', + {}, + ); + + // 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', + $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, @@ -622,9 +712,9 @@ describe('Account', () => { }); 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', + $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, @@ -659,9 +749,9 @@ describe('Account', () => { }); 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', + $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, @@ -686,8 +776,8 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -706,8 +796,8 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -727,8 +817,8 @@ describe('Account', () => { }); test('test method createRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -744,8 +834,8 @@ describe('Account', () => { }); test('test method updateRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -788,9 +878,9 @@ describe('Account', () => { }); 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', + $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', @@ -828,9 +918,9 @@ describe('Account', () => { }); 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', + $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', @@ -871,9 +961,9 @@ describe('Account', () => { }); test('test method createIdTokenSession()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -914,9 +1004,9 @@ describe('Account', () => { }); 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', + $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', @@ -957,9 +1047,9 @@ describe('Account', () => { }); 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', + $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', @@ -1000,9 +1090,9 @@ describe('Account', () => { }); 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', + $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', @@ -1040,9 +1130,9 @@ describe('Account', () => { }); 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', + $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', @@ -1080,9 +1170,9 @@ describe('Account', () => { }); 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', + $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', @@ -1130,9 +1220,9 @@ describe('Account', () => { }); 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', + $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, @@ -1157,8 +1247,8 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1177,8 +1267,8 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1205,10 +1295,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('<CHALLENGE_ID>', {}); + + // 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', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1227,8 +1350,8 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1246,8 +1369,8 @@ describe('Account', () => { }); test('test method createVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1265,8 +1388,8 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1285,8 +1408,8 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1305,8 +1428,8 @@ describe('Account', () => { }); test('test method createEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1322,8 +1445,8 @@ describe('Account', () => { }); test('test method updateEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1342,8 +1465,8 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1359,8 +1482,8 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 5270074..4c59cab 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', actorType: 'user', actorId: '610fc2f985ee0', actorEmail: 'john@appwrite.io', diff --git a/test/services/advisor.test.js b/test/services/advisor.test.js index 777728a..b3ff64d 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -26,9 +26,9 @@ describe('Advisor', () => { }); 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', + $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/', @@ -71,9 +71,9 @@ describe('Advisor', () => { }); 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', + $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', diff --git a/test/services/apps.test.js b/test/services/apps.test.js index d79c42c..a63e37e 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -26,9 +26,9 @@ describe('Apps', () => { }); 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', + $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', @@ -89,9 +89,9 @@ describe('Apps', () => { }); 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', + $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', @@ -126,9 +126,9 @@ describe('Apps', () => { }); 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', + $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', @@ -186,9 +186,9 @@ describe('Apps', () => { }); 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', + $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: [], @@ -254,9 +254,9 @@ describe('Apps', () => { }); 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', + $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', @@ -273,9 +273,9 @@ describe('Apps', () => { }); 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', + $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', @@ -302,9 +302,9 @@ describe('Apps', () => { }); 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', + $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', @@ -352,9 +352,9 @@ describe('Apps', () => { }); 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', + $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', @@ -371,9 +371,9 @@ describe('Apps', () => { }); 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', + $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', @@ -400,9 +400,9 @@ describe('Apps', () => { }); 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', + $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', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index c65b1b9..ecd4504 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -84,9 +84,9 @@ describe('Avatars', () => { }); test('test method updatePhoto()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 922f68d..e1db580 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -26,9 +26,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -45,9 +45,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -87,10 +87,10 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -113,10 +113,10 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -134,10 +134,10 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -165,9 +165,9 @@ describe('Backups', () => { }); 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', + $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', @@ -199,9 +199,9 @@ describe('Backups', () => { }); 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', + $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', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2af87b0..502bcb0 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -26,10 +26,10 @@ describe('Databases', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -56,9 +56,9 @@ describe('Databases', () => { }); 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', + $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', @@ -73,9 +73,9 @@ describe('Databases', () => { }); 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', + $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', @@ -90,9 +90,9 @@ describe('Databases', () => { }); 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', + $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', @@ -117,9 +117,9 @@ describe('Databases', () => { }); 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', + $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', @@ -134,10 +134,10 @@ describe('Databases', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -151,10 +151,10 @@ describe('Databases', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,10 +191,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -218,10 +218,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -244,10 +244,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -304,8 +304,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -327,8 +327,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -351,8 +351,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -374,8 +374,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -398,8 +398,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -422,8 +422,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -447,8 +447,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -471,8 +471,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -496,8 +496,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -522,8 +522,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -549,8 +549,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -572,8 +572,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -596,8 +596,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -619,8 +619,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -643,8 +643,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -667,8 +667,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -692,8 +692,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -715,8 +715,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -738,8 +738,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -761,8 +761,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -785,8 +785,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -808,8 +808,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -832,8 +832,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -855,8 +855,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -878,8 +878,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -901,8 +901,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -924,8 +924,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -953,8 +953,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -981,8 +981,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1006,8 +1006,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1031,8 +1031,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1054,8 +1054,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1078,8 +1078,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1102,8 +1102,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1127,8 +1127,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1152,8 +1152,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1177,8 +1177,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1225,13 +1225,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1314,13 +1314,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1336,13 +1336,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1358,13 +1358,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1394,13 +1394,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1417,13 +1417,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1456,9 +1456,9 @@ describe('Databases', () => { }); 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', + $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', @@ -1482,9 +1482,9 @@ describe('Databases', () => { }); 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', + $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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..b56872d 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -26,10 +26,10 @@ describe('DocumentsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -132,9 +132,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -149,10 +149,10 @@ describe('DocumentsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -166,10 +166,10 @@ describe('DocumentsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -206,10 +206,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -259,10 +259,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -315,13 +315,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -404,13 +404,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -426,13 +426,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -448,13 +448,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -484,13 +484,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -507,13 +507,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -546,9 +546,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -572,9 +572,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -610,21 +610,17 @@ describe('DocumentsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/domains.test.js b/test/services/domains.test.js index fc86018..f77cb0e 100644 --- a/test/services/domains.test.js +++ b/test/services/domains.test.js @@ -26,9 +26,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -79,9 +79,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -112,9 +112,9 @@ describe('Domains', () => { }); test('test method updateNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -135,9 +135,9 @@ describe('Domains', () => { }); test('test method verifyNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -328,9 +328,9 @@ describe('Domains', () => { }); test('test method createRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -356,9 +356,9 @@ describe('Domains', () => { }); test('test method updateRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -385,9 +385,9 @@ describe('Domains', () => { }); test('test method createRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -413,9 +413,9 @@ describe('Domains', () => { }); test('test method updateRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -442,9 +442,9 @@ describe('Domains', () => { }); test('test method createRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -470,9 +470,9 @@ describe('Domains', () => { }); test('test method updateRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -499,9 +499,9 @@ describe('Domains', () => { }); test('test method createRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -527,9 +527,9 @@ describe('Domains', () => { }); test('test method updateRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -556,9 +556,9 @@ describe('Domains', () => { }); test('test method createRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -584,9 +584,9 @@ describe('Domains', () => { }); test('test method updateRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -613,9 +613,9 @@ describe('Domains', () => { }); test('test method createRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -641,9 +641,9 @@ describe('Domains', () => { }); test('test method updateRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -670,9 +670,9 @@ describe('Domains', () => { }); test('test method createRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -699,9 +699,9 @@ describe('Domains', () => { }); test('test method updateRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -729,9 +729,9 @@ describe('Domains', () => { }); test('test method createRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -757,9 +757,9 @@ describe('Domains', () => { }); test('test method updateRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -786,9 +786,9 @@ describe('Domains', () => { }); test('test method createRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -817,9 +817,9 @@ describe('Domains', () => { }); test('test method updateRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -849,9 +849,9 @@ describe('Domains', () => { }); test('test method createRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -876,9 +876,9 @@ describe('Domains', () => { }); test('test method updateRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -905,9 +905,9 @@ describe('Domains', () => { }); test('test method getRecord()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -941,9 +941,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -988,9 +988,9 @@ describe('Domains', () => { }); test('test method updateZone()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', diff --git a/test/services/functions.test.js b/test/services/functions.test.js index fba574b..b40183d 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -27,9 +27,9 @@ describe('Functions', () => { }); 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', + $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, @@ -100,9 +100,9 @@ describe('Functions', () => { }); 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', + $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, @@ -143,9 +143,9 @@ describe('Functions', () => { }); 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', + $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, @@ -196,9 +196,9 @@ describe('Functions', () => { }); 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', + $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, @@ -255,9 +255,9 @@ describe('Functions', () => { }); 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', + $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', @@ -300,9 +300,9 @@ describe('Functions', () => { }); 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', + $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', @@ -344,9 +344,9 @@ describe('Functions', () => { }); 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', + $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', @@ -392,9 +392,9 @@ describe('Functions', () => { }); 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', + $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', @@ -437,9 +437,9 @@ describe('Functions', () => { }); 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', + $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', @@ -507,9 +507,9 @@ describe('Functions', () => { }); 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', + $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', @@ -564,10 +564,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -593,10 +593,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -651,9 +651,9 @@ describe('Functions', () => { }); 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', + $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, @@ -675,9 +675,9 @@ describe('Functions', () => { }); 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', + $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, @@ -697,9 +697,9 @@ describe('Functions', () => { }); 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', + $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, diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 25df258..3ffc4e3 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -26,9 +26,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -51,9 +51,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -72,9 +72,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -93,9 +93,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -114,9 +114,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -135,9 +135,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -156,9 +156,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -177,9 +177,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -198,9 +198,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -255,9 +255,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -277,9 +277,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -299,9 +299,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -318,9 +318,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -337,9 +337,9 @@ describe('Messaging', () => { }); test('test method createAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -359,9 +359,9 @@ describe('Messaging', () => { }); test('test method updateAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -379,9 +379,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -401,9 +401,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -423,9 +423,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -442,9 +442,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -461,9 +461,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -483,9 +483,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -502,9 +502,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -524,9 +524,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -543,9 +543,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -565,9 +565,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -584,9 +584,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -606,9 +606,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -626,9 +626,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -648,9 +648,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -667,9 +667,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -690,9 +690,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -713,9 +713,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -732,9 +732,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -751,9 +751,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -773,9 +773,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -793,9 +793,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -815,9 +815,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -835,9 +835,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -857,9 +857,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -876,9 +876,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -898,9 +898,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -917,9 +917,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -959,9 +959,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -978,9 +978,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -997,9 +997,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -1039,9 +1039,9 @@ describe('Messaging', () => { }); 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', + $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', @@ -1063,9 +1063,9 @@ describe('Messaging', () => { }); 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', + $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', diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..1df9e5f 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -26,21 +26,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mongo', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mongo', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mongo', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mongo', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mongo', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mongo', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -586,21 +566,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -647,21 +623,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -712,21 +684,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -829,17 +797,12 @@ describe('Mongo', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -852,17 +815,12 @@ describe('Mongo', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -900,21 +858,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..f9a83f3 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -26,21 +26,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mysql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mysql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mysql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mysql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mysql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mysql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -603,21 +583,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -664,21 +640,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -729,21 +701,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -888,17 +856,12 @@ describe('Mysql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -911,17 +874,12 @@ describe('Mysql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -959,21 +917,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 476045a..79d73e5 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -70,9 +70,9 @@ describe('Oauth2', () => { }); 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', + $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: [], @@ -94,9 +94,9 @@ describe('Oauth2', () => { }); 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', + $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: [], diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..e955287 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -13,9 +13,9 @@ describe('Organization', () => { 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', + $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: {}, @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -46,9 +39,9 @@ describe('Organization', () => { }); 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', + $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: {}, @@ -57,13 +50,6 @@ describe('Organization', () => { 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', @@ -102,9 +88,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -122,9 +108,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -143,9 +129,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -188,9 +174,9 @@ describe('Organization', () => { }); 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', + $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', @@ -214,9 +200,9 @@ describe('Organization', () => { }); 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', + $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', @@ -240,9 +226,9 @@ describe('Organization', () => { }); 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', + $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', @@ -292,9 +278,9 @@ describe('Organization', () => { }); 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', + $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', @@ -332,9 +318,9 @@ describe('Organization', () => { }); 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', + $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', @@ -369,9 +355,9 @@ describe('Organization', () => { }); 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', + $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', @@ -432,9 +418,9 @@ describe('Organization', () => { }); test('test method createEphemeralProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -456,9 +442,9 @@ describe('Organization', () => { }); test('test method getProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -479,9 +465,9 @@ describe('Organization', () => { }); test('test method updateProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..67244cf 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -26,21 +26,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Postgresql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Postgresql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Postgresql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Postgresql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Postgresql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -445,21 +433,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,21 +490,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -570,8 +550,8 @@ describe('Postgresql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -623,21 +603,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -687,21 +663,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -751,21 +723,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -812,21 +780,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -877,21 +841,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1039,17 +999,12 @@ describe('Postgresql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1062,17 +1017,12 @@ describe('Postgresql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1110,21 +1060,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/presences.test.js b/test/services/presences.test.js index b388216..ee08169 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -26,10 +26,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -43,10 +43,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -64,10 +64,10 @@ describe('Presences', () => { }); 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': [], + $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', }; diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..13066dc 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -13,9 +13,9 @@ describe('Project', () => { 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', + $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', @@ -60,9 +60,9 @@ describe('Project', () => { }); 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', + $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', @@ -95,6 +95,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment('<ENVIRONMENT_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment('<ENVIRONMENT_ID>'); + + // 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, @@ -110,9 +250,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -130,9 +270,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -150,9 +290,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -180,9 +320,9 @@ describe('Project', () => { }); 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', + $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', @@ -232,8 +372,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -247,8 +387,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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'); @@ -262,8 +402,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -298,9 +438,9 @@ describe('Project', () => { }); 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', + $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', @@ -338,7 +478,7 @@ describe('Project', () => { }); test('test method updateOAuth2Amazon()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', @@ -355,7 +495,7 @@ describe('Project', () => { }); test('test method updateOAuth2Apple()', async () => { const data = { - '\\$id': 'apple', + $id: 'apple', enabled: true, serviceId: 'ip.appwrite.app.web', keyId: 'P4000000N8', @@ -374,7 +514,7 @@ describe('Project', () => { }); test('test method updateOAuth2Appwrite()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a42000000000000b5a0', clientSecret: @@ -390,7 +530,7 @@ describe('Project', () => { }); test('test method updateOAuth2Auth0()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'OaOkIA000000000000000000005KLSYq', clientSecret: @@ -408,7 +548,7 @@ describe('Project', () => { }); test('test method updateOAuth2Authentik()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dTKOPa0000000000000000000000000000e7G8hv', clientSecret: @@ -425,7 +565,7 @@ describe('Project', () => { }); test('test method updateOAuth2Autodesk()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '5zw90v00000000000000000000kVYXN7', clientSecret: '7I000000000000MW', @@ -440,7 +580,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitbucket()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, key: 'Knt70000000000ByRc', secret: 'NMfLZJ00000000000000000000TLQdDx', @@ -455,7 +595,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitly()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'd95151000000000000000000000000000067af9b', clientSecret: 'a13e250000000000000000000000000000d73095', @@ -470,7 +610,7 @@ describe('Project', () => { }); test('test method updateOAuth2Box()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'deglcs00000000000000000000x2og6y', clientSecret: 'OKM1f100000000000000000000eshEif', @@ -485,7 +625,7 @@ describe('Project', () => { }); test('test method updateOAuth2Cloudflare()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '4b866000000000000000000000c9e4e2', clientSecret: @@ -501,7 +641,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dailymotion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, apiKey: '07a9000000000000067f', apiSecret: 'a399a90000000000000000000000000000d90639', @@ -516,7 +656,7 @@ describe('Project', () => { }); test('test method updateOAuth2Discord()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '950722000000343754', clientSecret: 'YmPXnM000000000000000000002zFg5D', @@ -532,7 +672,7 @@ describe('Project', () => { }); test('test method updateOAuth2Disqus()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, publicKey: 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', @@ -549,7 +689,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dropbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appKey: 'jl000000000009t', appSecret: 'g200000000000vw', @@ -564,7 +704,7 @@ describe('Project', () => { }); test('test method updateOAuth2Etsy()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, keyString: 'nsgzxh0000000000008j85a2', sharedSecret: 'tp000000ru', @@ -579,7 +719,7 @@ describe('Project', () => { }); test('test method updateOAuth2Facebook()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appId: '260600000007694', appSecret: '2d0b2800000000000000000000d38af4', @@ -594,7 +734,7 @@ describe('Project', () => { }); test('test method updateOAuth2Figma()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'byay5H0000000000VtiI40', clientSecret: 'yEpOYn0000000000000000004iIsU5', @@ -609,7 +749,7 @@ describe('Project', () => { }); test('test method updateOAuth2FusionAuth()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'b2222c00-0000-0000-0000-000000862097', clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', @@ -625,7 +765,7 @@ describe('Project', () => { }); test('test method updateOAuth2GitHub()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'e4d87900000000540733', clientSecret: '5e07c00000000000000000000000000000198bcc', @@ -641,7 +781,7 @@ describe('Project', () => { }); test('test method updateOAuth2Gitlab()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', @@ -658,7 +798,7 @@ describe('Project', () => { }); test('test method updateOAuth2Google()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', @@ -677,7 +817,7 @@ describe('Project', () => { }); test('test method updateOAuth2HuggingFace()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', @@ -692,7 +832,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kakao()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -708,7 +848,7 @@ describe('Project', () => { }); test('test method updateOAuth2Keycloak()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-o0000000st-app', clientSecret: 'jdjrJd00000000000000000000HUsaZO', @@ -725,7 +865,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kick()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '01KQ7C00000000000001MFHS32', clientSecret: @@ -741,7 +881,7 @@ describe('Project', () => { }); test('test method updateOAuth2Linkedin()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '770000000000dv', primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', @@ -756,7 +896,7 @@ describe('Project', () => { }); test('test method updateOAuth2Microsoft()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', @@ -773,7 +913,7 @@ describe('Project', () => { }); test('test method updateOAuth2Notion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauthClientId: '341d8700-0000-0000-0000-000000446ee3', oauthClientSecret: @@ -789,7 +929,7 @@ describe('Project', () => { }); test('test method updateOAuth2Oidc()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'qibI2x0000000000000000000000000006L2YFoG', clientSecret: @@ -811,7 +951,7 @@ describe('Project', () => { }); test('test method updateOAuth2Okta()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '0oa00000000000000698', clientSecret: @@ -830,7 +970,7 @@ describe('Project', () => { }); test('test method updateOAuth2Paypal()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -847,7 +987,7 @@ describe('Project', () => { }); test('test method updateOAuth2PaypalSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -864,7 +1004,7 @@ describe('Project', () => { }); test('test method updateOAuth2Podio()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-oauth-test-app', clientSecret: @@ -880,7 +1020,7 @@ describe('Project', () => { }); test('test method updateOAuth2Resend()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', clientSecret: @@ -896,7 +1036,7 @@ describe('Project', () => { }); test('test method updateOAuth2Salesforce()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', @@ -913,7 +1053,7 @@ describe('Project', () => { }); test('test method updateOAuth2Slack()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '23000000089.15000000000023', clientSecret: '81656000000000000000000000f3d2fd', @@ -928,7 +1068,7 @@ describe('Project', () => { }); test('test method updateOAuth2Spotify()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6ec271000000000000000000009beace', clientSecret: 'db068a000000000000000000008b5b9f', @@ -943,7 +1083,7 @@ describe('Project', () => { }); test('test method updateOAuth2Stripe()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'ca_UKibXX0000000000000000000006byvR', apiSecretKey: @@ -959,7 +1099,7 @@ describe('Project', () => { }); test('test method updateOAuth2TikTok()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'awz000000000tyw0', clientSecret: '6wXewM00000000000000000000yXnite', @@ -974,7 +1114,7 @@ describe('Project', () => { }); test('test method updateOAuth2Tradeshift()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -989,7 +1129,7 @@ describe('Project', () => { }); test('test method updateOAuth2TradeshiftSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -1004,7 +1144,7 @@ describe('Project', () => { }); test('test method updateOAuth2Twitch()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'vvi0in000000000000000000ikmt9p', clientSecret: 'pmapue000000000000000000zylw3v', @@ -1019,7 +1159,7 @@ describe('Project', () => { }); test('test method updateOAuth2Webflow()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '8bb20000000000000000000000000000000000000000000000000000000040dd', @@ -1036,7 +1176,7 @@ describe('Project', () => { }); test('test method updateOAuth2WordPress()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '130005', clientSecret: @@ -1052,7 +1192,7 @@ describe('Project', () => { }); test('test method updateOAuth2X()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: 'slzZV0000000000000NFLaWT', secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', @@ -1067,7 +1207,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yahoo()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', @@ -1083,7 +1223,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yandex()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a8a6a0000000000000000000091483c', clientSecret: 'bbf98500000000000000000000c75a63', @@ -1098,7 +1238,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoho()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '1000.83C178000000000000000000RPNX0B', clientSecret: 'fb5cac000000000000000000000000000000a68f6e', @@ -1114,7 +1254,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoom()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'QMAC00000000000000w0AQ', clientSecret: 'GAWsG4000000000000000000007U01ON', @@ -1129,7 +1269,7 @@ describe('Project', () => { }); test('test method getOAuth2Provider()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -1158,12 +1298,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1179,12 +1320,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1200,9 +1342,9 @@ describe('Project', () => { }); 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', + $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', @@ -1221,9 +1363,9 @@ describe('Project', () => { }); 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', + $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', @@ -1242,9 +1384,9 @@ describe('Project', () => { }); 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', + $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', @@ -1263,9 +1405,9 @@ describe('Project', () => { }); 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', + $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', @@ -1284,9 +1426,9 @@ describe('Project', () => { }); 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', + $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', @@ -1305,9 +1447,9 @@ describe('Project', () => { }); 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', + $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', @@ -1326,9 +1468,9 @@ describe('Project', () => { }); 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', + $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', @@ -1347,9 +1489,9 @@ describe('Project', () => { }); 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', + $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', @@ -1368,9 +1510,9 @@ describe('Project', () => { }); 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', + $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', @@ -1408,9 +1550,9 @@ describe('Project', () => { }); 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', + $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', @@ -1445,9 +1587,9 @@ describe('Project', () => { }); 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', + $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', @@ -1482,9 +1624,9 @@ describe('Project', () => { }); 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', + $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', @@ -1519,9 +1661,9 @@ describe('Project', () => { }); 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', + $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', @@ -1556,9 +1698,9 @@ describe('Project', () => { }); 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', + $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', @@ -1593,9 +1735,9 @@ describe('Project', () => { }); 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', + $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', @@ -1628,11 +1770,48 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy('<RP_ID>'); + + // 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', + $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', @@ -1667,9 +1846,9 @@ describe('Project', () => { }); 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', + $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', @@ -1704,9 +1883,9 @@ describe('Project', () => { }); 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', + $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', @@ -1741,9 +1920,9 @@ describe('Project', () => { }); test('test method updatePasswordPwnedPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -1776,9 +1955,46 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', + $id: 'password-dictionary', min: 12, uppercase: true, lowercase: true, @@ -1795,9 +2011,9 @@ describe('Project', () => { }); 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', + $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', @@ -1832,9 +2048,9 @@ describe('Project', () => { }); 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', + $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', @@ -1869,9 +2085,9 @@ describe('Project', () => { }); 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', + $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', @@ -1906,9 +2122,9 @@ describe('Project', () => { }); 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', + $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', @@ -1943,9 +2159,9 @@ describe('Project', () => { }); 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', + $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', @@ -1980,8 +2196,9 @@ describe('Project', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', - enabled: true, + $id: 'password-dictionary', + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); @@ -1993,9 +2210,9 @@ describe('Project', () => { }); 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', + $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', @@ -2030,9 +2247,9 @@ describe('Project', () => { }); 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', + $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', @@ -2067,9 +2284,9 @@ describe('Project', () => { }); 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', + $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', @@ -2178,9 +2395,9 @@ describe('Project', () => { }); 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', + $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, @@ -2201,9 +2418,9 @@ describe('Project', () => { }); 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', + $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, @@ -2220,9 +2437,9 @@ describe('Project', () => { }); 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', + $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, diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js index bf9d288..08576c6 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -41,9 +41,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -66,9 +66,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -94,9 +94,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -125,9 +125,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -150,9 +150,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -185,9 +185,9 @@ describe('Proxy', () => { }); 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', + $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', diff --git a/test/services/sites.test.js b/test/services/sites.test.js index 8e558d9..cf30e82 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -27,9 +27,9 @@ describe('Sites', () => { }); 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', + $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, @@ -104,9 +104,9 @@ describe('Sites', () => { }); 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', + $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, @@ -150,9 +150,9 @@ describe('Sites', () => { }); 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', + $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, @@ -206,9 +206,9 @@ describe('Sites', () => { }); 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', + $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, @@ -268,9 +268,9 @@ describe('Sites', () => { }); 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', + $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', @@ -312,9 +312,9 @@ describe('Sites', () => { }); 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', + $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', @@ -356,9 +356,9 @@ describe('Sites', () => { }); 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', + $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', @@ -404,9 +404,9 @@ describe('Sites', () => { }); 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', + $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', @@ -449,9 +449,9 @@ describe('Sites', () => { }); 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', + $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', @@ -519,9 +519,9 @@ describe('Sites', () => { }); 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', + $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', @@ -576,10 +576,10 @@ describe('Sites', () => { }); 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': [], + $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', @@ -628,9 +628,9 @@ describe('Sites', () => { }); 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', + $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, @@ -652,9 +652,9 @@ describe('Sites', () => { }); 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', + $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, @@ -671,9 +671,9 @@ describe('Sites', () => { }); 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', + $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, diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 7f35319..b46b168 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -27,10 +27,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -52,10 +52,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -77,10 +77,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -125,11 +125,11 @@ describe('Storage', () => { }); test('test method createFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -156,11 +156,11 @@ describe('Storage', () => { }); test('test method getFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -183,11 +183,11 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..6320233 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -26,10 +26,10 @@ describe('TablesDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('TablesDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('TablesDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,21 +191,17 @@ describe('TablesDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -265,9 +261,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -296,9 +292,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -340,9 +336,9 @@ describe('TablesDB', () => { }); test('test method createCutover()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -436,10 +432,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -463,10 +459,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -486,10 +482,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -546,8 +542,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -569,8 +565,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -593,8 +589,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -616,8 +612,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -640,8 +636,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -664,8 +660,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -689,8 +685,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -713,8 +709,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -738,8 +734,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -764,8 +760,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -791,8 +787,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -814,8 +810,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -838,8 +834,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -861,8 +857,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -885,8 +881,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -909,8 +905,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -934,8 +930,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -957,8 +953,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -980,8 +976,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1003,8 +999,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1027,8 +1023,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1050,8 +1046,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1074,8 +1070,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1097,8 +1093,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1120,8 +1116,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1143,8 +1139,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1166,8 +1162,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1195,8 +1191,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1223,8 +1219,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1248,8 +1244,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1273,8 +1269,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1296,8 +1292,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1320,8 +1316,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1344,8 +1340,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1369,8 +1365,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1394,8 +1390,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1419,8 +1415,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1467,9 +1463,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1493,9 +1489,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1544,13 +1540,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1633,13 +1629,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1655,13 +1651,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1677,13 +1673,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1713,13 +1709,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1736,13 +1732,13 @@ describe('TablesDB', () => { }); 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': [], + $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( diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 7dcf744..0248491 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -26,9 +26,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -43,9 +43,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -60,9 +60,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -100,9 +100,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -123,9 +123,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -146,9 +146,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -195,9 +195,9 @@ describe('Teams', () => { }); 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', + $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', @@ -221,9 +221,9 @@ describe('Teams', () => { }); 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', + $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', @@ -250,9 +250,9 @@ describe('Teams', () => { }); 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', + $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', @@ -293,9 +293,9 @@ describe('Teams', () => { }); 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', + $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', diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index 323ab93..1850b2e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -26,8 +26,8 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -47,8 +47,8 @@ describe('Tokens', () => { }); test('test method get()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -65,8 +65,8 @@ describe('Tokens', () => { }); test('test method update()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..21befd9 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -26,9 +26,9 @@ describe('Users', () => { }); 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', + $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, @@ -53,9 +53,9 @@ describe('Users', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Users', () => { }); 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', + $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, @@ -138,9 +138,9 @@ describe('Users', () => { }); 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', + $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, @@ -169,9 +169,9 @@ describe('Users', () => { }); 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', + $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, @@ -200,9 +200,9 @@ describe('Users', () => { }); 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', + $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, @@ -236,9 +236,9 @@ describe('Users', () => { }); 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', + $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, @@ -270,9 +270,9 @@ describe('Users', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Users', () => { }); 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', + $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, @@ -338,9 +338,9 @@ describe('Users', () => { }); 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', + $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, @@ -368,9 +368,9 @@ describe('Users', () => { }); 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', + $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, @@ -407,9 +407,9 @@ describe('Users', () => { }); 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', + $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, @@ -447,9 +447,9 @@ describe('Users', () => { }); 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', + $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, @@ -474,9 +474,9 @@ describe('Users', () => { }); 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', + $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, @@ -527,8 +527,8 @@ describe('Users', () => { }); test('test method getMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', code: '446372', @@ -650,9 +650,9 @@ describe('Users', () => { }); 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', + $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, @@ -675,11 +675,70 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys('<USER_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('<USER_ID>', '<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '<USER_ID>', + '<PASSKEY_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('<USER_ID>', '<PASSKEY_ID>'); + + // 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', + $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, @@ -704,9 +763,9 @@ describe('Users', () => { }); 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', + $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, @@ -764,9 +823,9 @@ describe('Users', () => { }); 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', + $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', @@ -824,9 +883,9 @@ describe('Users', () => { }); 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', + $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, @@ -864,9 +923,9 @@ describe('Users', () => { }); 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', + $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', @@ -888,9 +947,9 @@ describe('Users', () => { }); 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', + $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', @@ -907,9 +966,9 @@ describe('Users', () => { }); 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', + $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', @@ -936,8 +995,8 @@ describe('Users', () => { }); test('test method createToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -953,9 +1012,9 @@ describe('Users', () => { }); 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', + $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, @@ -980,9 +1039,9 @@ describe('Users', () => { }); 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', + $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, diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..4fe8681 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -26,10 +26,10 @@ describe('VectorsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('VectorsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('VectorsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -204,10 +204,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -260,10 +260,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -317,13 +317,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -422,13 +422,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -444,13 +444,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -466,13 +466,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -518,9 +518,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -544,9 +544,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -582,21 +582,17 @@ describe('VectorsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..1e672a2 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('<RULE_ID>', 'api', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '<RULE_ID>', + 'api', + '<NAME>', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '<RULE_ID>', + 'api', + '<NAME>', + '<LOCATION>', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule('<RULE_ID>'); + + // 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 7f7e54b..d232fb5 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -26,9 +26,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -55,9 +55,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -79,9 +79,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -118,9 +118,9 @@ describe('Webhooks', () => { }); 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', + $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: [], From 013085c5185f9a87a98e07fea4d8f065f107f390 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal <chiragaggarwal5k@gmail.com> Date: Thu, 15 Oct 2026 11:09:42 +0100 Subject: [PATCH 5/7] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 88 +- README.md | 58 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/domains/get-price.md | 2 +- docs/examples/domains/list-prices.md | 2 +- docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 2 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/update-email.md | 10 +- docs/examples/messaging/update-push.md | 4 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/mongo/create-restoration.md | 3 + docs/examples/mongo/promote-restoration.md | 15 + docs/examples/mysql/create-restoration.md | 3 + docs/examples/mysql/promote-restoration.md | 15 + docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../examples/postgresql/create-restoration.md | 3 + .../postgresql/promote-restoration.md | 15 + .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 +- .../project/update-o-auth-2-auth-0.md | 2 +- .../project/update-o-auth-2-discord.md | 2 +- .../project/update-o-auth-2-git-hub.md | 2 +- .../project/update-o-auth-2-google.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 2 +- .../project/update-o-auth-2-microsoft.md | 2 +- docs/examples/project/update-o-auth-2-okta.md | 2 +- .../project/update-o-auth-2-salesforce.md | 2 +- docs/examples/project/update-o-auth-2-zoho.md | 2 +- .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/proxy/create-smtp-rule.md | 16 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 88 +- src/enums/databases-index-type.ts | 1 + src/enums/execution-trigger.ts | 1 + src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/proxy-rule-protocol.ts | 4 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 15 +- src/models.ts | 1150 ++- src/query.ts | 809 ++ src/services/account.ts | 2254 ++++- src/services/activities.ts | 102 +- src/services/advisor.ts | 229 +- src/services/apps.ts | 633 +- src/services/backups.ts | 355 +- src/services/databases.ts | 3189 +++++-- src/services/documents-db.ts | 1179 ++- src/services/domains.ts | 1398 ++- src/services/embeddings.ts | 35 +- src/services/functions.ts | 1072 ++- src/services/locale.ts | 211 +- src/services/messaging.ts | 3171 ++++--- src/services/mongo.ts | 1826 +++- src/services/mysql.ts | 2084 ++++- src/services/oauth-2.ts | 359 +- src/services/organization.ts | 735 +- src/services/postgresql.ts | 2229 ++++- src/services/presences.ts | 94 +- src/services/project.ts | 7877 +++++++++++++---- src/services/proxy.ts | 340 +- src/services/sites.ts | 979 +- src/services/storage.ts | 326 +- src/services/tables-db.ts | 3648 ++++++-- src/services/teams.ts | 380 +- src/services/tokens.ts | 142 +- src/services/users.ts | 1808 +++- src/services/vectors-db.ts | 1181 ++- src/services/waf.ts | 2415 +++++ src/services/webhooks.ts | 217 +- src/topic.ts | 51 +- test/client.test.js | 53 + test/query.test.js | 457 +- test/services/account.test.js | 329 +- test/services/activities.test.js | 2 +- test/services/advisor.test.js | 12 +- test/services/apps.test.js | 60 +- test/services/avatars.test.js | 6 +- test/services/backups.test.js | 42 +- test/services/databases.test.js | 310 +- test/services/documents-d-b.test.js | 172 +- test/services/domains.test.js | 162 +- test/services/functions.test.js | 94 +- test/services/messaging.test.js | 282 +- test/services/mongo.test.js | 162 +- test/services/mysql.test.js | 162 +- test/services/oauth2.test.js | 12 +- test/services/organization.test.js | 98 +- test/services/postgresql.test.js | 182 +- test/services/presences.test.js | 24 +- test/services/project.test.js | 569 +- test/services/proxy.test.js | 71 +- test/services/sites.test.js | 86 +- test/services/storage.test.js | 48 +- test/services/tables-d-b.test.js | 338 +- test/services/teams.test.js | 60 +- test/services/tokens.test.js | 12 +- test/services/users.test.js | 211 +- test/services/vectors-d-b.test.js | 144 +- test/services/waf.test.js | 354 + test/services/webhooks.test.js | 24 +- test/topic.test.js | 20 +- 143 files changed, 39209 insertions(+), 8784 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/mongo/promote-restoration.md create mode 100644 docs/examples/mysql/promote-restoration.md create mode 100644 docs/examples/postgresql/promote-restoration.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/proxy/create-smtp-rule.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/proxy-rule-protocol.ts create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..b02f189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,70 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - ## 30.0.0 -* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed -* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed -* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` -* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model -* Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `account.createIdTokenSession` and email verification and recovery OTP methods +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models +* Breaking: removed `organization.createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `organization.listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead +* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys` +* Breaking: removed `BillingPlanGroup.Starter`; use `BillingPlanGroup.Free` +* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `string[]` +* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage` +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `mongo`, `mysql` and `postgresql` `promoteRestoration`, `restoreMode`, `targetName` and `autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration.restoreMode` +* Added: `proxy.createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule.protocol` +* Added: `emailEnabled` on `functions.update` and `Function`, and `ExecutionTrigger.Email` +* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page` +* Added: `Query.builder()` to chain queries into a list +* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider +* Updated: missing response fields fall back to their documented defaults +* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned +* Fixed: list and object defaults filled into a response are copied per model, and object defaults are `{}` instead of `[]` + +## 29.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers -* Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics -* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + +## 29.3.1 + +* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys +* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy + +## 29.3.0 + +* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification` +* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in +* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey` +* Added: `project.updatePasskeyPolicy` to configure passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..a2881b8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) @@ -50,7 +50,13 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```js let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -73,7 +79,13 @@ client ; let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -84,11 +96,11 @@ promise.then(function (response) { ### Type Safety with Models -The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. +The Appwrite Node SDK provides type safety when working with table rows through generic methods. Methods like `listRows`, `getRow`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. **TypeScript:** ```typescript -interface Book { +interface Book extends Models.Row { name: string; author: string; releaseYear?: string; @@ -97,15 +109,15 @@ interface Book { isCheckedOut: boolean; } -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - const documents = await databases.listDocuments<Book>( - 'your-database-id', - 'your-collection-id' - ); + const result = await tablesDB.listRows<Book>({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety }); } catch (error) { @@ -125,16 +137,16 @@ try { * @property {boolean} isCheckedOut */ -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - /** @type {Models.DocumentList<Book>} */ - const documents = await databases.listDocuments( - 'your-database-id', - 'your-collection-id' - ); + /** @type {Models.RowList<Book>} */ + const result = await tablesDB.listRows({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE }); } catch (error) { @@ -152,7 +164,13 @@ The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` a let users = new sdk.Users(client); try { - let res = await users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); + let res = await users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); } catch(e) { console.log(e.message); } diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '<STATE>', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '<PASSKEY_ID>', // optional + name: '<NAME>', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '<CHALLENGE_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '<PASSKEY_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index ff77675..893f3f0 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.getPrice({ domain: 'example.com', - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index bcf3572..86de02c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.listPrices({ domains: [], - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..a9c4c9d 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,7 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional + emailEnabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 499e392..256234c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -18,10 +18,10 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional - replyToEmail: 'email@example.com', // optional - replyToName: '<REPLY_TO_NAME>', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 04e86f7..0fc7a9a 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -10,18 +10,18 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateEmail({ messageId: '<MESSAGE_ID>', - subject: '<SUBJECT>', // optional - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional cc: [], // optional bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional replyToEmail: 'email@example.com', // optional replyToName: '<REPLY_TO_NAME>', // optional - draft: false, // optional - html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index d62e346..5d0e6b7 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -10,11 +10,11 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updatePush({ messageId: '<MESSAGE_ID>', - title: '<TITLE>', // optional - body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional data: {}, // optional action: '<ACTION>', // optional image: '<ID1:ID2>', // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 7c95f4f..940474a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,10 +10,10 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + content: '<CONTENT>', // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 7a6f1a3..326620f 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -14,5 +14,8 @@ const result = await mongo.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mongo/promote-restoration.md b/docs/examples/mongo/promote-restoration.md new file mode 100644 index 0000000..dc19b5c --- /dev/null +++ b/docs/examples/mongo/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mongo = new sdk.Mongo(client); + +const result = await mongo.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index 6e95f01..9e4843c 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -14,5 +14,8 @@ const result = await mysql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mysql/promote-restoration.md b/docs/examples/mysql/promote-restoration.md new file mode 100644 index 0000000..8aa43ed --- /dev/null +++ b/docs/examples/mysql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mysql = new sdk.Mysql(client); + +const result = await mysql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '<CLIENT_ID>', // optional scope: '<SCOPE>', // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '<CLIENT_SECRET>', // optional codeVerifier: '<CODE_VERIFIER>', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index 5cc8ea0..9647966 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -14,5 +14,8 @@ const result = await postgresql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/postgresql/promote-restoration.md b/docs/examples/postgresql/promote-restoration.md new file mode 100644 index 0000000..48e87af --- /dev/null +++ b/docs/examples/postgresql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const postgresql = new sdk.Postgresql(client); + +const result = await postgresql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..c0add3b --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..5400831 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..417f5c8 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..88d3d57 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..14bb9a8 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 9319a90..e1392e0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,8 +13,8 @@ const result = await project.updateOAuth2Apple({ keyId: '<KEY_ID>', // optional teamId: '<TEAM_ID>', // optional p8File: '<P8_FILE>', // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 61fb73c..79ba89d 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional endpoint: '<ENDPOINT>', // optional - prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index d76ac95..a8d5282 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index cb497db..8d3fbdd 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 0325eef..fc081aa 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,8 +12,8 @@ const result = await project.updateOAuth2Google({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index cb310ae..af88267 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kakao({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7a7edb2..2cb3efe 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '<APPLICATION_ID>', // optional applicationSecret: '<APPLICATION_SECRET>', // optional tenant: '<TENANT>', // optional - prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 4b6deba..7f0052b 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -13,7 +13,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '<CLIENT_SECRET>', // optional domain: 'example.com', // optional authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional - prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 12698d0..ffd57c0 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '<CUSTOMER_KEY>', // optional customerSecret: '<CUSTOMER_SECRET>', // optional - prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index baa7bc8..2ccc10d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '<RP_ID>', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/proxy/create-smtp-rule.md b/docs/examples/proxy/create-smtp-rule.md new file mode 100644 index 0000000..28691f6 --- /dev/null +++ b/docs/examples/proxy/create-smtp-rule.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const proxy = new sdk.Proxy(client); + +const result = await proxy.createSMTPRule({ + domain: 'example.com', + functionId: '<FUNCTION_ID>', + branch: '<BRANCH>', // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..2d45ad5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional + membershipId: '<MEMBERSHIP_ID>', // optional }); ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '<USER_ID>', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + location: '<LOCATION>', + statusCode: 300, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + location: '<LOCATION>', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..b36b64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..9272cdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..041b3ef 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { fetch, FormData, File, Agent, type RequestInit } from 'undici'; import { Models } from './models'; import { InputFile } from './inputFile'; +import { flattenParam } from './query'; import JSONbigModule from 'json-bigint'; const JSONbigParser = JSONbigModule({ storeAsString: false }); const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true }); @@ -44,6 +45,79 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record<string, unknown>; + properties?: Record<string, DefaultsShape>; +}; + +type Defaults = { + root: DefaultsShape; + models: Record<string, DefaultsModel>; +}; + +export function applyDefaults<T>(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function cloneDefault(value: unknown): unknown { + if (Array.isArray(value)) { + return value.map(cloneDefault); + } + if (typeof value === 'object' && value !== null) { + const copy: Record<string, unknown> = {}; + for (const [key, member] of Object.entries(value)) { + copy[key] = cloneDefault(member); + } + return copy; + } + return value; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record<string, DefaultsModel>, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record<string, unknown> = { ...model.defaults, ...value }; + // Each item gets its own copy of a filled-in list or object, so mutating one doesn't change the rest + for (const key of Object.keys(model.defaults ?? {})) { + if (!Object.prototype.hasOwnProperty.call(value, key)) { + result[key] = cloneDefault(result[key]); + } + } + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + // The spread drops the non-enumerable JSON toString that Client.call attaches. + if (Object.prototype.hasOwnProperty.call(value, 'toString')) { + Object.defineProperty(result, 'toString', { + value: () => JSONbig.stringify(result), + writable: true, + enumerable: false, + configurable: true, + }); + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +154,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +215,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.5.0', }; /** @@ -394,6 +468,10 @@ class Client { ): { uri: string; options: RequestInit } { method = method.toUpperCase(); + for (const key of Object.keys(params)) { + params[key] = flattenParam(params[key]); + } + headers = Object.assign({}, this.headers, headers); const options: RequestInit = { @@ -887,6 +965,6 @@ class Client { } export { Client, AppwriteException }; -export { Query } from './query'; +export { Query, QueryBuilder, flattenParam } from './query'; export type { Models, Payload, UploadProgress }; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833..275668e 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts index 84fa8f6..b16a878 100644 --- a/src/enums/execution-trigger.ts +++ b/src/enums/execution-trigger.ts @@ -2,4 +2,5 @@ export enum ExecutionTrigger { Http = 'http', Schedule = 'schedule', Event = 'event', + Email = 'email', } diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/proxy-rule-protocol.ts b/src/enums/proxy-rule-protocol.ts new file mode 100644 index 0000000..1ed23de --- /dev/null +++ b/src/enums/proxy-rule-protocol.ts @@ -0,0 +1,4 @@ +export enum ProxyRuleProtocol { + Http = 'http', + Smtp = 'smtp', +} diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4..09fd95c 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..e0da2f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,10 @@ -export { Client, Query, AppwriteException } from './client'; +export { + Client, + Query, + QueryBuilder, + flattenParam, + AppwriteException, +} from './client'; export { Account } from './services/account'; export { Activities } from './services/activities'; export { Apps } from './services/apps'; @@ -28,13 +34,14 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; -export { Topic, ResolvedTopic } from './topic'; +export { Topic } from './topic'; export { Operator, Condition } from './operator'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; @@ -116,6 +123,8 @@ export { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; export { PlatformType } from './enums/platform-type'; export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; export { ProxyRuleStatus } from './enums/proxy-rule-status'; +export { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..9ceb01a 100644 --- a/src/models.ts +++ b/src/models.ts @@ -22,9 +22,11 @@ import { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; import { PlatformType } from './enums/platform-type'; import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; import { ProxyRuleStatus } from './enums/proxy-rule-status'; +import { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +505,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +517,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -744,39 +748,39 @@ export namespace Models { /** * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ - status?: DatabaseStatus; + status?: DatabaseStatus | null; /** * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ - engine?: string; + engine?: string | null; /** * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. */ - specification?: string; + specification?: string | null; /** * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ - replicas?: number; + replicas?: number | null; /** * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. */ - error?: string; + error?: string | null; /** * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. */ - containerStatus?: string; + containerStatus?: string | null; /** * 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; + lifecycleState?: string | null; /** * Database backup policies. */ - policies?: BackupPolicy[]; + policies?: BackupPolicy[] | null; /** * Database backup archives. */ - archives?: BackupArchive[]; + archives?: BackupArchive[] | null; }; /** @@ -934,7 +938,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -950,11 +954,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -984,7 +988,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -996,15 +1000,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1034,7 +1038,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1046,15 +1050,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -1084,7 +1088,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1096,15 +1100,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1134,7 +1138,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1146,7 +1150,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -1176,7 +1180,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1192,7 +1196,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1222,7 +1226,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1242,7 +1246,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1272,7 +1276,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1288,7 +1292,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1318,7 +1322,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1334,7 +1338,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1364,7 +1368,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1380,7 +1384,7 @@ export namespace Models { /** * Default value for attribute when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -1410,7 +1414,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1472,7 +1476,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1484,7 +1488,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -1514,7 +1518,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1526,7 +1530,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -1556,7 +1560,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1568,7 +1572,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -1598,7 +1602,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1614,11 +1618,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1648,7 +1652,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1660,11 +1664,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1694,7 +1698,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1706,11 +1710,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1740,7 +1744,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1752,11 +1756,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1844,7 +1848,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1882,7 +1886,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -2030,7 +2034,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2046,11 +2050,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2080,7 +2084,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2092,15 +2096,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2130,7 +2134,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2142,15 +2146,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -2180,7 +2184,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2192,15 +2196,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2230,7 +2234,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2242,7 +2246,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -2272,7 +2276,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2288,7 +2292,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2318,7 +2322,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2338,7 +2342,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2368,7 +2372,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2384,7 +2388,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2414,7 +2418,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2430,7 +2434,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2460,7 +2464,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2476,7 +2480,7 @@ export namespace Models { /** * Default value for column when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -2506,7 +2510,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2568,7 +2572,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2580,7 +2584,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -2610,7 +2614,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2622,7 +2626,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -2652,7 +2656,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2664,7 +2668,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -2694,7 +2698,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2710,11 +2714,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2744,7 +2748,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2756,11 +2760,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2790,7 +2794,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2802,11 +2806,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2836,7 +2840,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2848,11 +2852,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2898,7 +2902,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -2944,7 +2948,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -3052,7 +3056,7 @@ export namespace Models { /** * Presence status. */ - status?: string; + status?: string | null; /** * Presence source. */ @@ -3060,7 +3064,7 @@ export namespace Models { /** * Presence expiry date in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * Presence metadata. */ @@ -3092,15 +3096,15 @@ export namespace Models { /** * Hashed user password. */ - password?: string; + password?: string | null; /** * Password hashing algorithm. */ - hash?: string; + hash?: string | null; /** * Password hashing algorithm configuration. */ - hashOptions?: object; + hashOptions?: object | null; /** * User registration date in ISO 8601 format. */ @@ -3132,27 +3136,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3176,11 +3180,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3346,27 +3350,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3390,11 +3394,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3654,47 +3658,47 @@ export namespace Models { /** * City */ - city?: string; + city?: string | null; /** * Name of timezone */ - timeZone?: string; + timeZone?: string | null; /** * Postal code */ - postalCode?: string; + postalCode?: string | null; /** * Latitude */ - latitude?: number; + latitude?: number | null; /** * Longitude */ - longitude?: number; + longitude?: number | null; /** * Autonomous System Number (ASN) of the IP */ - autonomousSystemNumber?: string; + autonomousSystemNumber?: string | null; /** * Organization that owns the ASN */ - autonomousSystemOrganization?: string; + autonomousSystemOrganization?: string | null; /** * Internet service provider of the IP */ - isp?: string; + isp?: string | null; /** * Connection type of the IP (e.g. cable, cellular, corporate) */ - connectionType?: string; + connectionType?: string | null; /** * User type classification of the IP (e.g. residential, business, hosting) */ - connectionUsageType?: string; + connectionUsageType?: string | null; /** * Registered organization of the IP */ - connectionOrganization?: string; + connectionOrganization?: string | null; }; /** @@ -4201,6 +4205,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number | null; /** * Function execution timeout in seconds. */ @@ -4253,6 +4261,10 @@ export namespace Models { * Machine specification for executions. */ runtimeSpecification: string; + /** + * Whether inbound email (SMTP) may trigger this function. Opt-in; default is false. When disabled, recipients for this function are rejected. + */ + emailEnabled?: boolean | null; }; /** @@ -4342,7 +4354,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile?: string; + fallbackFile?: string | null; }; /** @@ -4492,7 +4504,7 @@ export namespace Models { */ deploymentId: string; /** - * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. + * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, `event`, or `email`. */ trigger: ExecutionTrigger; /** @@ -4538,7 +4550,7 @@ export namespace Models { /** * The scheduled time for execution. If left empty, execution will be queued immediately. */ - scheduledAt?: string; + scheduledAt?: string | null; }; /** @@ -4652,87 +4664,91 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled?: boolean; + wafEnabled?: boolean | null; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * First time the project received a non-console API request. Empty until the project is used. */ - firstAccessedAt?: string; + firstAccessedAt?: string | null; /** * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. */ - mcpAccessedAt?: string; + mcpAccessedAt?: string | null; /** * OAuth2 server status */ - oAuth2ServerEnabled?: boolean; + oAuth2ServerEnabled?: boolean | null; /** * OAuth2 server authorization URL */ - oAuth2ServerAuthorizationUrl?: string; + oAuth2ServerAuthorizationUrl?: string | null; /** * OAuth2 server allowed scopes */ - oAuth2ServerScopes?: string[]; + oAuth2ServerScopes?: string[] | null; /** * OAuth2 server scopes used when an authorization request omits the scope parameter */ - oAuth2ServerDefaultScopes?: string[]; + oAuth2ServerDefaultScopes?: string[] | null; /** * Scopes an application may request when installed on a team */ - oAuth2ServerInstallationScopes?: string[]; + oAuth2ServerInstallationScopes?: string[] | null; /** * OAuth2 server accepted RFC 9396 authorization_details types */ - oAuth2ServerAuthorizationDetailsTypes?: string[]; + oAuth2ServerAuthorizationDetailsTypes?: string[] | null; /** * OAuth2 server access token duration in seconds for confidential clients */ - oAuth2ServerAccessTokenDuration?: number; + oAuth2ServerAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for confidential clients */ - oAuth2ServerRefreshTokenDuration?: number; + oAuth2ServerRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicAccessTokenDuration?: number; + oAuth2ServerPublicAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicRefreshTokenDuration?: number; + oAuth2ServerPublicRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for app installation access tokens */ - oAuth2ServerInstallationAccessTokenDuration?: number; + oAuth2ServerInstallationAccessTokenDuration?: number | null; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ - oAuth2ServerConfidentialPkce?: boolean; + oAuth2ServerConfidentialPkce?: boolean | null; /** * URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured. */ - oAuth2ServerVerificationUrl?: string; + oAuth2ServerVerificationUrl?: string | null; /** * Number of characters in the device flow user code, excluding the formatting separator. */ - oAuth2ServerUserCodeLength?: number; + oAuth2ServerUserCodeLength?: number | null; /** * Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`. */ - oAuth2ServerUserCodeFormat?: string; + oAuth2ServerUserCodeFormat?: string | null; /** * Lifetime in seconds of device flow device codes and user codes. */ - oAuth2ServerDeviceCodeDuration?: number; + oAuth2ServerDeviceCodeDuration?: number | null; /** * OAuth2 server discovery URL */ - oAuth2ServerDiscoveryUrl?: string; + oAuth2ServerDiscoveryUrl?: string | null; }; /** @@ -5898,7 +5914,7 @@ export namespace Models { /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ - maxAge?: number; + maxAge?: number | null; }; /** @@ -6251,6 +6267,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6415,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6577,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6822,7 +6878,7 @@ export namespace Models { /** * Type of deployment resource: function, site, or dedicatedDatabase. */ - deploymentResourceType?: ProxyRuleDeploymentResourceType; + deploymentResourceType?: ProxyRuleDeploymentResourceType | null; /** * ID of deployment's resource (site or function ID). Used if type is "deployment" */ @@ -6843,6 +6899,10 @@ export namespace Models { * Certificate auto-renewal date in ISO 8601 format. */ renewAt: string; + /** + * Ingress protocol for the rule. + */ + protocol: ProxyRuleProtocol; }; /** @@ -6931,6 +6991,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -7058,15 +7214,15 @@ export namespace Models { /** * The scheduled time for message. */ - scheduledAt?: string; + scheduledAt?: string | null; /** * The time when the message was delivered. */ - deliveredAt?: string; + deliveredAt?: string | null; /** * Delivery errors if any. */ - deliveryErrors?: string[]; + deliveryErrors?: string[] | null; /** * Number of recipients the message was delivered to. */ @@ -7120,11 +7276,11 @@ export namespace Models { /** * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. */ - qos?: number; + qos?: number | null; /** - * Message retention in seconds for offline delivery. + * Message retention in seconds for offline delivery. Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. */ - expiry?: number; + expiry?: number | null; }; /** @@ -7226,7 +7382,7 @@ export namespace Models { /** * Provider ID. */ - providerId?: string; + providerId?: string | null; /** * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ @@ -7304,15 +7460,15 @@ export namespace Models { /** * Time the insight was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; /** * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - dismissedAt?: string; + dismissedAt?: string | null; /** * User ID that dismissed the insight. Empty when not dismissed. */ - dismissedBy?: string; + dismissedBy?: string | null; }; /** @@ -7388,7 +7544,7 @@ export namespace Models { /** * Time the report was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; }; /** @@ -7566,7 +7722,7 @@ export namespace Models { /** * Archive size in bytes. Null until the size is known. */ - size?: number; + size?: number | null; /** * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ @@ -7574,7 +7730,7 @@ export namespace Models { /** * The backup start time. Null until the backup starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -7590,11 +7746,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this archive should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this archive should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; }; /** @@ -7648,23 +7804,23 @@ export namespace Models { /** * Backup start time in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Backup completion time in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Backup verification time in ISO 8601 format. */ - verifiedAt?: string; + verifiedAt?: string | null; /** * Backup expiration time in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * 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; + logPosition?: string | null; /** * Error message if backup failed. */ @@ -7718,35 +7874,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth?: number; + bandwidth?: number | null; /** * Storage limit */ - storage?: number; + storage?: number | null; /** * Users limit */ - users?: number; + users?: number | null; /** * Executions limit */ - executions?: number; + executions?: number | null; /** * GBHours limit */ - GBHours?: number; + GBHours?: number | null; /** * Image transformations limit */ - imageTransformations?: number; + imageTransformations?: number | null; /** * Auth phone limit */ - authPhone?: number; + authPhone?: number | null; /** * Budget limit percentage */ - budgetLimit?: number; + budgetLimit?: number | null; }; /** @@ -7796,7 +7952,7 @@ export namespace Models { /** * Members */ - members?: number; + members?: number | null; /** * Webhooks */ @@ -7805,6 +7961,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments: number; /** * Projects */ @@ -7892,7 +8052,7 @@ export namespace Models { /** * Activity log days */ - activityLogs?: number; + activityLogs?: number | null; /** * Usage history days */ @@ -7900,11 +8060,11 @@ export namespace Models { /** * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ - usageLogsIntervals?: string[]; + usageLogsIntervals?: string[] | null; /** * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. */ - usageAggregateOnlyMetrics?: string[]; + usageAggregateOnlyMetrics?: string[] | null; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -7916,7 +8076,7 @@ export namespace Models { /** * Additional resources. Null when the plan does not support usage billing. */ - usage?: UsageBillingPlan; + usage?: UsageBillingPlan | null; /** * Addons */ @@ -7944,7 +8104,7 @@ export namespace Models { /** * ISO country codes eligible for this regional plan. Empty means no restriction. */ - eligibleCountries?: string[]; + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8000,7 +8160,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled?: boolean; + backupsEnabled?: boolean | null; /** * Whether usage addons are calculated per project. */ @@ -8012,7 +8172,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies?: number; + backupPolicies?: number | null; /** * Maximum function and site deployment size in MB */ @@ -8021,6 +8181,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8028,7 +8192,7 @@ export namespace Models { /** * Plan specific limits */ - limits?: BillingPlanLimits; + limits?: BillingPlanLimits | null; /** * Group of this billing plan for variants */ @@ -8036,7 +8200,7 @@ export namespace Models { /** * Details of the program this plan is a part of. */ - program?: Program; + program?: Program | null; /** * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. */ @@ -8044,7 +8208,7 @@ export namespace Models { /** * Dedicated database limits available to this plan. */ - dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; + dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits | null; }; /** @@ -8054,11 +8218,11 @@ export namespace Models { /** * Addon seats */ - seats?: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails | null; /** * Addon projects */ - projects?: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails | null; }; /** @@ -8084,7 +8248,7 @@ export namespace Models { /** * Price currency */ - currency?: string; + currency?: string | null; /** * Price */ @@ -8106,11 +8270,11 @@ export namespace Models { /** * Credits limit per billing cycle */ - credits?: number; + credits?: number | null; /** * Daily credits limit (if applicable) */ - dailyCredits?: number; + dailyCredits?: number | null; }; /** @@ -8120,79 +8284,79 @@ export namespace Models { /** * Minimum CPU allocation in millicores. */ - minCpu?: number; + minCpu?: number | null; /** * Maximum CPU allocation in millicores. */ - maxCpu?: number; + maxCpu?: number | null; /** * Minimum memory allocation in megabytes. */ - minMemoryMb?: number; + minMemoryMb?: number | null; /** * Maximum memory allocation in megabytes. */ - maxMemoryMb?: number; + maxMemoryMb?: number | null; /** * Minimum storage allocation in gigabytes. */ - minStorageGb?: number; + minStorageGb?: number | null; /** * Maximum storage allocation in gigabytes. */ - maxStorageGb?: number; + maxStorageGb?: number | null; /** * Maximum number of high-availability replicas per dedicated database. */ - maxReplicas?: number; + maxReplicas?: number | null; /** * Maximum number of client connections. */ - maxConnections?: number; + maxConnections?: number | null; /** * Maximum number of entries allowed in the IP allowlist. */ - maxIpAllowlistSize?: number; + maxIpAllowlistSize?: number | null; /** * Maximum number of database extensions that can be enabled. */ - maxExtensions?: number; + maxExtensions?: number | null; /** * Maximum number of days a backup can be retained. */ - maxBackupRetentionDays?: number; + maxBackupRetentionDays?: number | null; /** * Maximum number of days of point-in-time recovery data that can be retained. */ - maxPitrRetentionDays?: number; + maxPitrRetentionDays?: number | null; /** * Maximum number of rows a single SQL API query can return. */ - maxSqlApiMaxRows?: number; + maxSqlApiMaxRows?: number | null; /** * Maximum response size in bytes for a single SQL API query. */ - maxSqlApiMaxBytes?: number; + maxSqlApiMaxBytes?: number | null; /** * Maximum execution time in seconds for a single SQL API query. */ - maxSqlApiTimeoutSeconds?: number; + maxSqlApiTimeoutSeconds?: number | null; /** * Maximum number of SQL statement types that can be permitted through the SQL API. */ - maxSqlApiAllowedStatements?: number; + maxSqlApiAllowedStatements?: number | null; /** * SQL statement types permitted through the SQL API. */ - allowedSqlStatements?: string[]; + allowedSqlStatements?: string[] | null; /** * Storage classes available for dedicated databases. */ - allowedStorageClasses?: string[]; + allowedStorageClasses?: string[] | null; /** * Replica synchronization modes available for dedicated databases. */ - allowedSyncModes?: string[]; + allowedSyncModes?: string[] | null; }; /** @@ -8236,7 +8400,7 @@ export namespace Models { /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - expiredAt?: string; + expiredAt?: string | null; }; /** @@ -8266,7 +8430,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number | null; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8572,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string | null; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string | null; /** * Database engine version. */ @@ -8432,7 +8596,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number | null; /** * Database username for connections. */ @@ -8444,7 +8608,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number | null; /** * Full database connection string (URI format). */ @@ -8464,11 +8628,11 @@ export namespace Models { /** * Last activity timestamp in ISO 8601 format. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; /** * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. */ - idleUntil?: string; + idleUntil?: string | null; /** * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. */ @@ -8500,7 +8664,7 @@ export namespace Models { /** * Time the in-flight storage resize started, in ISO 8601 format. */ - storageResizeStartedAt?: string; + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8658,7 +8822,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string | null; /** * Project ID. */ @@ -8666,11 +8830,15 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string | null; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ type: string; + /** + * Where the backup was restored. Possible values: in_place (replayed over the database that took the backup), clone (recovered onto a second workload beside the database, which keeps serving until the clone is promoted onto its endpoint), copy (recovered onto a separate database with its own endpoint). + */ + restoreMode: string; /** * Restoration status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). */ @@ -8678,15 +8846,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string | null; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string | null; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string | null; /** * Error message if restoration failed. */ @@ -8720,7 +8888,7 @@ export namespace Models { /** * Connection statistics. Null when the database has not been probed. */ - connections?: DatabaseStatusConnections; + connections?: DatabaseStatusConnections | null; /** * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. */ @@ -8728,7 +8896,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -8744,7 +8912,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -8856,7 +9024,7 @@ export namespace Models { /** * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus?: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum | null; /** * Team ID. */ @@ -8886,7 +9054,7 @@ export namespace Models { /** * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price?: number; + price?: number | null; /** * Price period in years. */ @@ -8898,7 +9066,7 @@ export namespace Models { /** * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. */ - renewalPrice?: number; + renewalPrice?: number | null; /** * Renewal price period in years. */ @@ -8960,11 +9128,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -8998,15 +9166,15 @@ export namespace Models { /** * Time the operation was requested, in ISO 8601 format. */ - requestedAt?: string; + requestedAt?: string | null; /** * Time the operation started, in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Time the operation reached a terminal state, in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ @@ -9046,7 +9214,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -9062,7 +9230,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * Per-pod statuses for the primary and every replica. */ @@ -9124,7 +9292,7 @@ export namespace Models { /** * Project budget limit. Null when no budget is set. */ - billingBudget?: number; + billingBudget?: number | null; /** * Project budget limit */ @@ -9148,43 +9316,43 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string | null; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string | null; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string | null; /** * Start date of trial. */ - billingTrialStartDate?: string; + billingTrialStartDate?: string | null; /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number | null; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string | null; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string | null; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string | null; /** * Default payment method. */ - billingAddressId?: string; + billingAddressId?: string | null; /** * Backup payment method. */ - backupPaymentMethodId?: string; + backupPaymentMethodId?: string | null; /** * Team status. */ @@ -9192,39 +9360,39 @@ export namespace Models { /** * Remarks on team status. */ - remarks?: string; + remarks?: string | null; /** * Organization agreements */ - agreementBAA?: string; + agreementBAA?: string | null; /** * Program manager's name. */ - programManagerName?: string; + programManagerName?: string | null; /** * Program manager's calendar link. */ - programManagerCalendar?: string; + programManagerCalendar?: string | null; /** * Program's discord channel name. */ - programDiscordChannelName?: string; + programDiscordChannelName?: string | null; /** * Program's discord channel URL. */ - programDiscordChannelUrl?: string; + programDiscordChannelUrl?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * Billing plan selected for downgrade. */ - billingPlanDowngrade?: string; + billingPlanDowngrade?: string | null; /** * Tax Id */ - billingTaxId?: string; + billingTaxId?: string | null; /** * Marked for deletion */ @@ -9284,11 +9452,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this policy should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this policy should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; /** * How many days to keep the backup before it will be automatically deleted. */ @@ -9448,7 +9616,7 @@ export namespace Models { /** * The restoration start time. Null until the restoration starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -9586,11 +9754,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -9622,47 +9790,47 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource | null; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource | null; /** * Member additional resources */ - member?: AdditionalResource; + member?: AdditionalResource | null; /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource | null; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource | null; /** * Realtime bandwidth additional resources */ - realtimeBandwidth?: AdditionalResource; + realtimeBandwidth?: AdditionalResource | null; /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource | null; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource | null; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource | null; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource | null; /** * Credits additional resources */ - credits?: AdditionalResource; + credits?: AdditionalResource | null; }; /** @@ -9814,7 +9982,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9856,7 +10024,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9928,7 +10096,7 @@ export namespace Models { /** * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9970,7 +10138,7 @@ export namespace Models { /** * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -10132,11 +10300,11 @@ export namespace Models { /** * Granted RFC 9396 authorization details as a JSON string. */ - authorization_details?: string; + authorization_details?: string | null; /** * OpenID Connect ID token. Returned when the `openid` scope is granted. */ - id_token?: string; + id_token?: string | null; }; /** @@ -10150,47 +10318,47 @@ export namespace Models { /** * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. */ - token_use?: string; + token_use?: string | null; /** * OAuth2 token type. */ - token_type?: string; + token_type?: string | null; /** * Space-separated scopes granted to the token. */ - scope?: string; + scope?: string | null; /** * OAuth2 client ID the token was issued to. */ - client_id?: string; + client_id?: string | null; /** * ID of the user who authorized the token. */ - sub?: string; + sub?: string | null; /** * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). */ - aud?: string[]; + aud?: string[] | null; /** * Issuer URL of the token. */ - iss?: string; + iss?: string | null; /** * Expiration time as a Unix timestamp in seconds. */ - exp?: number; + exp?: number | null; /** * Issued-at time as a Unix timestamp in seconds. */ - iat?: number; + iat?: number | null; /** * Unique identifier of the token. */ - jti?: string; + jti?: string | null; /** * Granted RFC 9396 authorization details, restricted to what the user can currently access. */ - authorization_details?: Record<string, any>[]; + authorization_details?: Record<string, any>[] | null; }; /** @@ -10289,6 +10457,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/query.ts b/src/query.ts index 7a7da88..6cce10a 100644 --- a/src/query.ts +++ b/src/query.ts @@ -468,6 +468,20 @@ export class Query { queries.map((query) => JSONbig.parse(query)), ).toString(); + /** + * Constrain populated related documents on a relationship attribute. + * + * @param {string} attribute The relationship attribute to query. + * @param {string[]} queries Filter, order, select, and pagination queries applied to related documents. + * @returns {string} + */ + static relationship = (attribute: string, queries: string[]): string => + new Query( + 'relationship', + attribute, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + /** * Filter resources where attribute is at a specific distance from the given coordinates. * @@ -659,4 +673,799 @@ export class Query { */ static notTouches = (attribute: string, values: any[]): string => new Query('notTouches', attribute, [values]).toString(); + + /** + * Count documents, optionally aliased. + */ + static count = (attribute: string = '*', alias: string = ''): string => + new Query( + 'count', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Count distinct values of attribute, optionally aliased. + */ + static countDistinct = (attribute: string, alias: string = ''): string => + new Query( + 'countDistinct', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sum values of `attribute`, optionally aliased. */ + static sum = (attribute: string, alias: string = ''): string => + new Query( + 'sum', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Average values of `attribute`, optionally aliased. */ + static avg = (attribute: string, alias: string = ''): string => + new Query( + 'avg', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Minimum value of `attribute`, optionally aliased. */ + static min = (attribute: string, alias: string = ''): string => + new Query( + 'min', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Maximum value of `attribute`, optionally aliased. */ + static max = (attribute: string, alias: string = ''): string => + new Query( + 'max', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Standard deviation of `attribute`, optionally aliased. */ + static stddev = (attribute: string, alias: string = ''): string => + new Query( + 'stddev', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population standard deviation of `attribute`, optionally aliased. */ + static stddevPop = (attribute: string, alias: string = ''): string => + new Query( + 'stddevPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample standard deviation of `attribute`, optionally aliased. */ + static stddevSamp = (attribute: string, alias: string = ''): string => + new Query( + 'stddevSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Variance of `attribute`, optionally aliased. */ + static variance = (attribute: string, alias: string = ''): string => + new Query( + 'variance', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population variance of `attribute`, optionally aliased. */ + static varPop = (attribute: string, alias: string = ''): string => + new Query( + 'varPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample variance of `attribute`, optionally aliased. */ + static varSamp = (attribute: string, alias: string = ''): string => + new Query( + 'varSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise AND of `attribute`, optionally aliased. */ + static bitAnd = (attribute: string, alias: string = ''): string => + new Query( + 'bitAnd', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise OR of `attribute`, optionally aliased. */ + static bitOr = (attribute: string, alias: string = ''): string => + new Query( + 'bitOr', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise XOR of `attribute`, optionally aliased. */ + static bitXor = (attribute: string, alias: string = ''): string => + new Query( + 'bitXor', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Group results by attributes. + */ + static groupBy = (attributes: string[]): string => + new Query('groupBy', undefined, attributes).toString(); + + /** + * Filter grouped results. `queries` are nested like `and`/`or`. + */ + static having = (queries: string[]): string => + new Query( + 'having', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** Select distinct rows. */ + static distinct = (): string => new Query('distinct').toString(); + + /** + * Column-to-column join ON condition. + */ + static on = (left: string, right: string, operator: string = '='): string => + new Query('on', undefined, [left, operator, right]).toString(); + + /** + * Inner join. `table` is the joined collection/table ID. + */ + static join = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'join', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Left join. `table` is the joined collection/table ID. */ + static leftJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'leftJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Right join. `table` is the joined collection/table ID. */ + static rightJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'rightJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Full outer join. `table` is the joined collection/table ID. */ + static fullOuterJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'fullOuterJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Cross join. `table` is the joined collection/table ID. */ + static crossJoin = (table: string, alias: string = ''): string => + new Query( + 'crossJoin', + table, + alias !== '' ? alias : undefined, + ).toString(); + + /** Filter resources where `attribute` covers the given geometry. */ + static covers = (attribute: string, values: any[]): string => + new Query('covers', attribute, [values]).toString(); + + /** Filter resources where `attribute` does not cover the given geometry. */ + static notCovers = (attribute: string, values: any[]): string => + new Query('notCovers', attribute, [values]).toString(); + + /** Filter resources where `attribute` is spatially equal to the given geometry. */ + static spatialEquals = (attribute: string, values: any[]): string => + new Query('spatialEquals', attribute, [values]).toString(); + + /** Filter resources where `attribute` is not spatially equal to the given geometry. */ + static notSpatialEquals = (attribute: string, values: any[]): string => + new Query('notSpatialEquals', attribute, [values]).toString(); + + /** + * Return limit and offset queries for 1-based page pagination. + */ + static page = (page: number, perPage: number = 25): string[] => { + if (page < 1) { + throw new Error('Page must be >= 1, got ' + page); + } + if (perPage < 1) { + throw new Error('Per page must be >= 1, got ' + perPage); + } + return [Query.limit(perPage), Query.offset((page - 1) * perPage)]; + }; + + /** Start a fluent query builder. */ + static builder = (): Query.Builder => new Query.Builder(); + + private static createJoin( + method: string, + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string { + if (Array.isArray(leftOrAliasOrOn)) { + return Query.nestedJoin(method, table, '', leftOrAliasOrOn); + } + if (Array.isArray(rightOrOn)) { + return Query.nestedJoin(method, table, leftOrAliasOrOn, rightOrOn); + } + return new Query( + method, + table, + alias !== '' + ? [leftOrAliasOrOn, operator, rightOrOn, alias] + : [leftOrAliasOrOn, operator, rightOrOn], + ).toString(); + } + + private static nestedJoin( + method: string, + table: string, + alias: string, + on: string[], + ): string { + const values: any[] = []; + if (alias !== '') { + values.push(alias); + } + for (const query of on) { + values.push(JSONbig.parse(query)); + } + return new Query(method, table, values).toString(); + } +} + +export type QueryInput = string | Query | Query.Builder | QueryInput[]; + +/** + * Fluent collector of Query fragments. Call {@link Query.Builder.build} to + * produce the `string[]` expected by list/createQuery methods. + */ +export namespace Query { + export class Builder { + private readonly queries: string[] = []; + + build(): string[] { + return [...this.queries]; + } + + equal(attribute: string, value: QueryTypes): this { + return this.push(Query.equal(attribute, value)); + } + + notEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.notEqual(attribute, value)); + } + + lessThan(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThan(attribute, value)); + } + + lessThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThanEqual(attribute, value)); + } + + greaterThan(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThan(attribute, value)); + } + + greaterThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThanEqual(attribute, value)); + } + + search(attribute: string, value: string): this { + return this.push(Query.search(attribute, value)); + } + + isNull(attribute: string): this { + return this.push(Query.isNull(attribute)); + } + + isNotNull(attribute: string): this { + return this.push(Query.isNotNull(attribute)); + } + + between( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.between(attribute, start, end)); + } + + startsWith(attribute: string, value: string): this { + return this.push(Query.startsWith(attribute, value)); + } + + endsWith(attribute: string, value: string): this { + return this.push(Query.endsWith(attribute, value)); + } + + select(attributes: string[]): this { + return this.push(Query.select(attributes)); + } + + cursorAfter(documentId: string): this { + return this.push(Query.cursorAfter(documentId)); + } + + cursorBefore(documentId: string): this { + return this.push(Query.cursorBefore(documentId)); + } + + orderAsc(attribute: string): this { + return this.push(Query.orderAsc(attribute)); + } + + orderDesc(attribute: string): this { + return this.push(Query.orderDesc(attribute)); + } + + orderRandom(): this { + return this.push(Query.orderRandom()); + } + + limit(limit: number): this { + return this.push(Query.limit(limit)); + } + + offset(offset: number): this { + return this.push(Query.offset(offset)); + } + + contains(attribute: string, value: string | any[]): this { + return this.push(Query.contains(attribute, value)); + } + + containsAny(attribute: string, value: any[]): this { + return this.push(Query.containsAny(attribute, value)); + } + + containsAll(attribute: string, value: any[]): this { + return this.push(Query.containsAll(attribute, value)); + } + + notContains(attribute: string, value: string | any[]): this { + return this.push(Query.notContains(attribute, value)); + } + + notSearch(attribute: string, value: string): this { + return this.push(Query.notSearch(attribute, value)); + } + + notBetween( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.notBetween(attribute, start, end)); + } + + notStartsWith(attribute: string, value: string): this { + return this.push(Query.notStartsWith(attribute, value)); + } + + notEndsWith(attribute: string, value: string): this { + return this.push(Query.notEndsWith(attribute, value)); + } + + regex(attribute: string, pattern: string): this { + return this.push(Query.regex(attribute, pattern)); + } + + exists(attributes: string[]): this { + return this.push(Query.exists(attributes)); + } + + notExists(attributes: string[]): this { + return this.push(Query.notExists(attributes)); + } + + createdBefore(value: string): this { + return this.push(Query.createdBefore(value)); + } + + createdAfter(value: string): this { + return this.push(Query.createdAfter(value)); + } + + createdBetween(start: string, end: string): this { + return this.push(Query.createdBetween(start, end)); + } + + updatedBefore(value: string): this { + return this.push(Query.updatedBefore(value)); + } + + updatedAfter(value: string): this { + return this.push(Query.updatedAfter(value)); + } + + updatedBetween(start: string, end: string): this { + return this.push(Query.updatedBetween(start, end)); + } + + or(queries: string[]): this { + return this.push(Query.or(queries)); + } + + and(queries: string[]): this { + return this.push(Query.and(queries)); + } + + elemMatch(attribute: string, queries: string[]): this { + return this.push(Query.elemMatch(attribute, queries)); + } + + relationship(attribute: string, queries: string[]): this { + return this.push(Query.relationship(attribute, queries)); + } + + distanceEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceEqual(attribute, values, distance, meters), + ); + } + + distanceNotEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceNotEqual(attribute, values, distance, meters), + ); + } + + distanceGreaterThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceGreaterThan(attribute, values, distance, meters), + ); + } + + distanceLessThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceLessThan(attribute, values, distance, meters), + ); + } + + intersects(attribute: string, values: any[]): this { + return this.push(Query.intersects(attribute, values)); + } + + notIntersects(attribute: string, values: any[]): this { + return this.push(Query.notIntersects(attribute, values)); + } + + crosses(attribute: string, values: any[]): this { + return this.push(Query.crosses(attribute, values)); + } + + notCrosses(attribute: string, values: any[]): this { + return this.push(Query.notCrosses(attribute, values)); + } + + overlaps(attribute: string, values: any[]): this { + return this.push(Query.overlaps(attribute, values)); + } + + notOverlaps(attribute: string, values: any[]): this { + return this.push(Query.notOverlaps(attribute, values)); + } + + touches(attribute: string, values: any[]): this { + return this.push(Query.touches(attribute, values)); + } + + notTouches(attribute: string, values: any[]): this { + return this.push(Query.notTouches(attribute, values)); + } + + count(attribute: string = '*', alias: string = ''): this { + return this.push(Query.count(attribute, alias)); + } + + countDistinct(attribute: string, alias: string = ''): this { + return this.push(Query.countDistinct(attribute, alias)); + } + + sum(attribute: string, alias: string = ''): this { + return this.push(Query.sum(attribute, alias)); + } + + avg(attribute: string, alias: string = ''): this { + return this.push(Query.avg(attribute, alias)); + } + + min(attribute: string, alias: string = ''): this { + return this.push(Query.min(attribute, alias)); + } + + max(attribute: string, alias: string = ''): this { + return this.push(Query.max(attribute, alias)); + } + + stddev(attribute: string, alias: string = ''): this { + return this.push(Query.stddev(attribute, alias)); + } + + stddevPop(attribute: string, alias: string = ''): this { + return this.push(Query.stddevPop(attribute, alias)); + } + + stddevSamp(attribute: string, alias: string = ''): this { + return this.push(Query.stddevSamp(attribute, alias)); + } + + variance(attribute: string, alias: string = ''): this { + return this.push(Query.variance(attribute, alias)); + } + + varPop(attribute: string, alias: string = ''): this { + return this.push(Query.varPop(attribute, alias)); + } + + varSamp(attribute: string, alias: string = ''): this { + return this.push(Query.varSamp(attribute, alias)); + } + + bitAnd(attribute: string, alias: string = ''): this { + return this.push(Query.bitAnd(attribute, alias)); + } + + bitOr(attribute: string, alias: string = ''): this { + return this.push(Query.bitOr(attribute, alias)); + } + + bitXor(attribute: string, alias: string = ''): this { + return this.push(Query.bitXor(attribute, alias)); + } + + groupBy(attributes: string[]): this { + return this.push(Query.groupBy(attributes)); + } + + having(queries: string[]): this { + return this.push(Query.having(queries)); + } + + distinct(): this { + return this.push(Query.distinct()); + } + + join( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.join(table, leftOrAliasOrOn, rightOrOn, operator, alias), + ); + } + + leftJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.leftJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + rightJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.rightJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + fullOuterJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.fullOuterJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + crossJoin(table: string, alias: string = ''): this { + return this.push(Query.crossJoin(table, alias)); + } + + vectorDot(attribute: string, vector: number[]): this { + return this.push(Query.vectorDot(attribute, vector)); + } + + vectorCosine(attribute: string, vector: number[]): this { + return this.push(Query.vectorCosine(attribute, vector)); + } + + vectorEuclidean(attribute: string, vector: number[]): this { + return this.push(Query.vectorEuclidean(attribute, vector)); + } + + covers(attribute: string, values: any[]): this { + return this.push(Query.covers(attribute, values)); + } + + notCovers(attribute: string, values: any[]): this { + return this.push(Query.notCovers(attribute, values)); + } + + spatialEquals(attribute: string, values: any[]): this { + return this.push(Query.spatialEquals(attribute, values)); + } + + notSpatialEquals(attribute: string, values: any[]): this { + return this.push(Query.notSpatialEquals(attribute, values)); + } + + page(page: number, perPage: number = 25): this { + return this.push(Query.page(page, perPage)); + } + + private push(query: string | string[]): this { + if (Array.isArray(query)) { + this.queries.push(...query); + } else { + this.queries.push(query); + } + return this; + } + } +} + +export function normalizeQueries(queries?: QueryInput | null): string[] { + if (queries == null) { + return []; + } + if (queries instanceof Query.Builder) { + return queries.build(); + } + if (!Array.isArray(queries)) { + if (queries instanceof Query) { + return [queries.toString()]; + } + if (typeof queries === 'string') { + return [queries]; + } + return []; + } + + const out: string[] = []; + for (const item of queries) { + out.push(...normalizeQueries(item)); + } + return out; } + +function isQueryValue(value: unknown): value is Query | Query.Builder { + return value instanceof Query.Builder || value instanceof Query; +} + +export function flattenParam(value: unknown): unknown { + if (isQueryValue(value)) { + return normalizeQueries(value); + } + if (!Array.isArray(value) || !value.some(isQueryValue)) { + return value; + } + + const out: unknown[] = []; + for (const item of value) { + if (isQueryValue(item)) { + out.push(...normalizeQueries(item)); + } else { + out.push(item); + } + } + return out; +} + +export const QueryBuilder = Query.Builder; +export type QueryBuilder = Query.Builder; diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..8c05720 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +186,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +297,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + consents: [], + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +542,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +648,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +824,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +935,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1084,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1185,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1348,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1470,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1684,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1850,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1966,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2026,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2061,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2097,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2128,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2161,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2193,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2226,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2258,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2330,538 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.PasskeyList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise<Models.PasskeyChallenge>; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise<Models.PasskeyChallenge>; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise<Models.PasskeyChallenge> { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { passkeyId: string }): Promise<Models.Passkey>; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise<Models.Passkey> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise<Models.Passkey>; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise<Models.Passkey>; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2940,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3062,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3189,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3300,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3411,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3502,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3611,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3679,58 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3802,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2389,14 +3852,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. - * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ createEmailPasswordSession(params: { email: string; password: string; - duration?: number; + duration?: number | null; }): Promise<Models.Session>; /** * 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. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. @@ -2405,7 +3868,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. - * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2413,14 +3876,19 @@ export class Account { createEmailPasswordSession( email: string, password: string, - duration?: number, + duration?: number | null, ): Promise<Models.Session>; createEmailPasswordSession( paramsOrFirst: - { email: string; password: string; duration?: number } | string, - ...rest: [string?, number?] + | { email: string; password: string; duration?: number | null } + | string, + ...rest: [string?, (number | null)?] ): Promise<Models.Session> { - let params: { email: string; password: string; duration?: number }; + let params: { + email: string; + password: string; + duration?: number | null; + }; if ( paramsOrFirst && @@ -2430,13 +3898,13 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; - duration?: number; + duration?: number | null; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, - duration: rest[1] as number, + duration: rest[1] as number | null, }; } @@ -2470,7 +3938,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4140,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4255,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4367,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4478,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4573,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4669,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4785,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4919,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5043,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5076,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} */ @@ -3259,6 +5085,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise<string>; /** * 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. @@ -3273,6 +5100,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5110,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise<string>; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5119,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise<string> { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5139,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5155,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5163,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5183,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5196,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskeyToken(): Promise<Models.PasskeyChallenge> { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise<Models.TokenSecret>; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise<Models.TokenSecret>; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.TokenSecret> { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5396,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5473,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5551,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5642,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5731,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5808,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5901,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5938,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6029,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..d082ca4 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,58 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + events: [], + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +171,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..b19ab4f 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,76 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + reports: [], + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +206,65 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +405,56 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +526,44 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..ff362ed 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,72 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + apps: [], + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +450,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +523,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +569,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +647,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1019,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1206,38 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1311,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1478,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1575,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1659,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1738,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1889,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2024,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2108,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2195,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2345,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..d8dfb94 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,41 +64,71 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + archives: [], + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} params.services - Array of services to backup - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} */ createArchive(params: { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }): Promise<Models.BackupArchive>; /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} services - Array of services to backup - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} * @deprecated Use the object parameter style method for a better developer experience. */ createArchive( services: BackupServices[], - resourceId?: string, + resourceId?: string | null, ): Promise<Models.BackupArchive>; createArchive( paramsOrFirst: - | { services: BackupServices[]; resourceId?: string } + | { services: BackupServices[]; resourceId?: string | null } | BackupServices[], - ...rest: [string?] + ...rest: [(string | null)?] ): Promise<Models.BackupArchive> { - let params: { services: BackupServices[]; resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string | null }; if ( paramsOrFirst && @@ -103,12 +138,12 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string, + resourceId: rest[0] as string | null, }; } @@ -135,7 +170,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +244,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +370,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +413,7 @@ export class Backups { * @param {number} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Schedule CRON syntax. * @param {string} params.name - Policy name. Max length: 128 chars. - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -319,7 +424,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }): Promise<Models.BackupPolicy>; /** @@ -330,7 +435,7 @@ export class Backups { * @param {number} retention - Days to keep backups before deletion * @param {string} schedule - Schedule CRON syntax. * @param {string} name - Policy name. Max length: 128 chars. - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -342,7 +447,7 @@ export class Backups { retention: number, schedule: string, name?: string, - resourceId?: string, + resourceId?: string | null, enabled?: boolean, ): Promise<Models.BackupPolicy>; createPolicy( @@ -353,7 +458,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; } | string, @@ -362,7 +467,7 @@ export class Backups { number?, string?, string?, - string?, + (string | null)?, boolean?, ] ): Promise<Models.BackupPolicy> { @@ -372,7 +477,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; @@ -387,7 +492,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; } else { @@ -397,7 +502,7 @@ export class Backups { retention: rest[1] as number, schedule: rest[2] as string, name: rest[3] as string, - resourceId: rest[4] as string, + resourceId: rest[4] as string | null, enabled: rest[5] as boolean, }; } @@ -460,7 +565,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,64 +641,90 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update an existing policy using it's ID. * * @param {string} params.policyId - Policy ID. Choose a custom ID`. 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 {number} params.retention - Days to keep backups before deletion + * @param {string | null} params.name - Policy name. Max length: 128 chars. + * @param {number | null} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Cron expression - * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updatePolicy(params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * Update an existing policy using it's ID. * * @param {string} policyId - Policy ID. Choose a custom ID`. 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 {number} retention - Days to keep backups before deletion + * @param {string | null} name - Policy name. Max length: 128 chars. + * @param {number | null} retention - Days to keep backups before deletion * @param {string} schedule - Cron expression - * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePolicy( policyId: string, - name?: string, - retention?: number, + name?: string | null, + retention?: number | null, schedule?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updatePolicy( paramsOrFirst: | { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, number?, string?, boolean?] + ...rest: [ + (string | null)?, + (number | null)?, + string?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -582,18 +734,18 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { policyId: paramsOrFirst as string, - name: rest[0] as string, - retention: rest[1] as number, + name: rest[0] as string | null, + retention: rest[1] as number | null, schedule: rest[2] as string, - enabled: rest[3] as boolean, + enabled: rest[3] as boolean | null, }; } @@ -632,7 +784,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +987,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1061,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1150,27 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..0b2d328 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,69 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +246,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +366,35 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +447,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +522,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +629,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +779,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +852,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +988,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1199,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -892,11 +1259,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. @@ -905,7 +1272,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -917,11 +1284,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,7 +1297,7 @@ export class Databases { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -942,7 +1309,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -952,7 +1319,7 @@ export class Databases { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -963,7 +1330,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -979,7 +1346,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -990,7 +1357,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1053,7 +1420,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1537,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1139,7 +1586,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1151,7 +1598,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1162,7 +1609,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1174,7 +1621,7 @@ export class Databases { databaseId: string, collectionId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1185,19 +1632,26 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Collection> { let params: { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1212,7 +1666,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1222,7 +1676,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -1276,7 +1730,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1955,20 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + attributes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1472,9 +1979,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1485,9 +1992,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeBigint>; /** @@ -1498,9 +2005,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1511,9 +2018,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeBigint>; createBigIntAttribute( @@ -1523,9 +2030,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -1533,9 +2040,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeBigint> { @@ -1544,9 +2051,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -1560,9 +2067,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -1571,9 +2078,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -1638,7 +2145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,10 +2173,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. @@ -1662,10 +2186,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeBigint>; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. @@ -1675,10 +2199,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1688,10 +2212,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeBigint>; updateBigIntAttribute( paramsOrFirst: @@ -1700,20 +2224,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeBigint> { let params: { @@ -1721,10 +2245,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -1737,10 +2261,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -1748,10 +2272,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -1818,7 +2342,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1829,7 +2370,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1840,7 +2381,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.AttributeBoolean>; /** @@ -1851,7 +2392,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1862,7 +2403,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.AttributeBoolean>; createBooleanAttribute( @@ -1872,18 +2413,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -1897,7 +2438,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -1906,7 +2447,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -1963,7 +2504,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1973,8 +2531,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. @@ -1984,8 +2542,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.AttributeBoolean>; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -1994,8 +2552,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2005,8 +2563,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.AttributeBoolean>; updateBooleanAttribute( paramsOrFirst: @@ -2015,19 +2573,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2040,8 +2604,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2049,8 +2613,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2109,7 +2673,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2119,7 +2700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2130,7 +2711,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeDatetime>; /** @@ -2140,7 +2721,7 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2151,7 +2732,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeDatetime>; createDatetimeAttribute( @@ -2161,18 +2742,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2186,7 +2767,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2195,7 +2776,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2252,7 +2833,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2262,8 +2860,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. @@ -2273,8 +2871,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeDatetime>; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -2283,8 +2881,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2294,8 +2892,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeDatetime>; updateDatetimeAttribute( paramsOrFirst: @@ -2304,19 +2902,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2329,8 +2933,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2338,8 +2942,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2398,7 +3002,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2409,7 +3030,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2420,7 +3041,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEmail>; /** @@ -2431,7 +3052,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2442,7 +3063,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEmail>; createEmailAttribute( @@ -2452,18 +3073,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2477,7 +3098,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2486,7 +3107,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2543,7 +3164,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2554,8 +3193,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. @@ -2565,8 +3204,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEmail>; /** * Update an email attribute. Changing the `default` value will not update already existing documents. @@ -2576,8 +3215,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2587,8 +3226,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEmail>; updateEmailAttribute( paramsOrFirst: @@ -2597,19 +3236,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2622,8 +3267,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2631,8 +3276,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2691,7 +3336,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2703,7 +3366,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2715,7 +3378,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEnum>; /** @@ -2727,7 +3390,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2739,7 +3402,7 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEnum>; createEnumAttribute( @@ -2750,11 +3413,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2762,7 +3432,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2777,7 +3447,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2787,7 +3457,7 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -2853,7 +3523,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2865,8 +3554,8 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. @@ -2877,8 +3566,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEnum>; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -2889,8 +3578,8 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2901,8 +3590,8 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEnum>; updateEnumAttribute( paramsOrFirst: @@ -2912,11 +3601,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2924,8 +3620,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2939,8 +3635,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2949,8 +3645,8 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3018,7 +3714,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3029,9 +3744,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3042,9 +3757,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.AttributeFloat>; /** @@ -3055,9 +3770,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3068,9 +3783,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.AttributeFloat>; createFloatAttribute( @@ -3080,9 +3795,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3090,9 +3805,9 @@ export class Databases { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.AttributeFloat> { @@ -3101,9 +3816,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3117,9 +3832,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3128,9 +3843,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3195,7 +3910,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3206,10 +3938,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {string} params.newKey - New Attribute Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. @@ -3219,10 +3951,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.AttributeFloat>; /** * Update a float attribute. Changing the `default` value will not update already existing documents. @@ -3232,10 +3964,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {string} newKey - New Attribute Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3245,10 +3977,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.AttributeFloat>; updateFloatAttribute( paramsOrFirst: @@ -3257,20 +3989,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.AttributeFloat> { let params: { @@ -3278,10 +4010,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3294,10 +4026,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3305,10 +4037,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -3375,7 +4107,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3386,9 +4135,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3399,9 +4148,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeInteger>; /** @@ -3412,9 +4161,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3425,9 +4174,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeInteger>; createIntegerAttribute( @@ -3437,9 +4186,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -3447,9 +4196,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeInteger> { @@ -3458,9 +4207,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -3474,9 +4223,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -3485,9 +4234,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -3552,7 +4301,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,10 +4329,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. @@ -3576,10 +4342,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeInteger>; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -3589,10 +4355,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3602,10 +4368,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeInteger>; updateIntegerAttribute( paramsOrFirst: @@ -3614,20 +4380,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeInteger> { let params: { @@ -3635,10 +4401,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -3651,10 +4417,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -3662,10 +4428,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -3732,7 +4498,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3743,7 +4526,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3754,7 +4537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeIp>; /** @@ -3765,7 +4548,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3776,7 +4559,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeIp>; createIpAttribute( @@ -3786,18 +4569,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3811,7 +4594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3820,7 +4603,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3877,7 +4660,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3888,8 +4689,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. @@ -3899,8 +4700,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeIp>; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -3910,8 +4711,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3921,8 +4722,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeIp>; updateIpAttribute( paramsOrFirst: @@ -3931,19 +4732,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3956,8 +4763,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3965,8 +4772,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4025,7 +4832,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4035,7 +4860,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. @@ -4045,7 +4870,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributeLine>; /** * Create a geometric line attribute. @@ -4054,7 +4879,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4064,7 +4889,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributeLine>; createLineAttribute( paramsOrFirst: @@ -4073,17 +4898,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4096,7 +4921,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4104,7 +4929,7 @@ export class Databases { 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[][] | null, }; } @@ -4156,7 +4981,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4166,8 +5008,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. @@ -4177,8 +5019,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributeLine>; /** * Update a line attribute. Changing the `default` value will not update already existing documents. @@ -4187,8 +5029,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4198,8 +5040,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributeLine>; updateLineAttribute( paramsOrFirst: @@ -4208,19 +5050,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4233,8 +5081,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4242,8 +5090,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4297,7 +5145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4308,7 +5173,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4320,7 +5185,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeLongtext>; @@ -4332,7 +5197,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4344,7 +5209,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeLongtext>; @@ -4355,19 +5220,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4382,7 +5254,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4392,7 +5264,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4454,7 +5326,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4465,8 +5354,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. @@ -4476,8 +5365,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeLongtext>; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -4487,8 +5376,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4498,8 +5387,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeLongtext>; updateLongtextAttribute( paramsOrFirst: @@ -4508,19 +5397,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4533,8 +5428,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4542,8 +5437,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4602,7 +5497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4613,7 +5525,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4625,7 +5537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeMediumtext>; @@ -4637,7 +5549,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4649,7 +5561,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeMediumtext>; @@ -4660,19 +5572,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4687,7 +5606,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4697,7 +5616,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4759,7 +5678,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4770,8 +5706,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. @@ -4781,8 +5717,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeMediumtext>; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -4792,8 +5728,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4803,8 +5739,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeMediumtext>; updateMediumtextAttribute( paramsOrFirst: @@ -4813,19 +5749,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4838,8 +5780,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4847,8 +5789,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4907,7 +5849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4917,7 +5876,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. @@ -4927,7 +5886,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.AttributePoint>; /** * Create a geometric point attribute. @@ -4936,7 +5895,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4946,7 +5905,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.AttributePoint>; createPointAttribute( paramsOrFirst: @@ -4955,17 +5914,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -4978,7 +5937,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -4986,7 +5945,7 @@ export class Databases { 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[] | null, }; } @@ -5038,7 +5997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5048,8 +6024,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. @@ -5059,8 +6035,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.AttributePoint>; /** * Update a point attribute. Changing the `default` value will not update already existing documents. @@ -5069,8 +6045,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5080,8 +6056,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.AttributePoint>; updatePointAttribute( paramsOrFirst: @@ -5090,19 +6066,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5115,8 +6097,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5124,8 +6106,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5179,7 +6161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5189,7 +6188,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. @@ -5199,7 +6198,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributePolygon>; /** * Create a geometric polygon attribute. @@ -5208,7 +6207,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5218,7 +6217,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributePolygon>; createPolygonAttribute( paramsOrFirst: @@ -5227,17 +6226,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5250,7 +6249,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5258,7 +6257,7 @@ export class Databases { 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[][] | null, }; } @@ -5310,7 +6309,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5320,8 +6336,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. @@ -5331,8 +6347,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributePolygon>; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -5341,8 +6357,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5352,8 +6368,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributePolygon>; updatePolygonAttribute( paramsOrFirst: @@ -5362,19 +6378,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -5387,8 +6409,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -5396,8 +6418,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -5451,7 +6473,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5463,8 +6502,8 @@ export class Databases { * @param {string} params.relatedCollectionId - Related Collection ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Attribute Key. - * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {string | null} params.key - Attribute Key. + * @param {string | null} params.twoWayKey - Two Way Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5476,8 +6515,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.AttributeRelationship>; /** @@ -5489,8 +6528,8 @@ export class Databases { * @param {string} relatedCollectionId - Related Collection ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Attribute Key. - * @param {string} twoWayKey - Two Way Attribute Key. + * @param {string | null} key - Attribute Key. + * @param {string | null} twoWayKey - Two Way Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5502,8 +6541,8 @@ export class Databases { relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.AttributeRelationship>; createRelationshipAttribute( @@ -5514,8 +6553,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -5524,8 +6563,8 @@ export class Databases { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.AttributeRelationship> { @@ -5535,8 +6574,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -5551,8 +6590,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -5562,8 +6601,8 @@ export class Databases { relatedCollectionId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -5628,7 +6667,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5639,7 +6700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. @@ -5649,7 +6710,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }): Promise<Models.AttributeRelationship>; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -5659,7 +6720,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Attribute Key. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5669,7 +6730,7 @@ export class Databases { collectionId: string, key: string, onDelete?: RelationMutate, - newKey?: string, + newKey?: string | null, ): Promise<Models.AttributeRelationship>; updateRelationshipAttribute( paramsOrFirst: @@ -5678,17 +6739,17 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, RelationMutate?, (string | null)?] ): Promise<Models.AttributeRelationship> { let params: { databaseId: string; collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; if ( @@ -5701,7 +6762,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; } else { params = { @@ -5709,7 +6770,7 @@ export class Databases { 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 | null, }; } @@ -5754,7 +6815,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5766,7 +6849,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for text attributes, in number of characters. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5779,7 +6862,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeString>; @@ -5792,7 +6875,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for text attributes, in number of characters. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5805,7 +6888,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeString>; @@ -5817,7 +6900,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -5827,7 +6910,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -5838,7 +6921,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5854,7 +6937,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5865,7 +6948,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -5934,7 +7017,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5945,9 +7046,9 @@ export class Databases { * @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). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the string attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the string attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. @@ -5957,9 +7058,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeString>; /** * Update a string attribute. Changing the `default` value will not update already existing documents. @@ -5969,9 +7070,9 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the string attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the string attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5981,9 +7082,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeString>; updateStringAttribute( paramsOrFirst: @@ -5992,21 +7093,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeString> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6019,9 +7127,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6029,9 +7137,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6094,7 +7202,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6105,7 +7231,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6117,7 +7243,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeText>; @@ -6129,7 +7255,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6141,7 +7267,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeText>; @@ -6152,19 +7278,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6179,7 +7312,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6189,7 +7322,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6251,7 +7384,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6262,8 +7412,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6273,8 +7423,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeText>; /** * Update a text attribute. Changing the `default` value will not update already existing documents. @@ -6284,8 +7434,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6295,8 +7445,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeText>; updateTextAttribute( paramsOrFirst: @@ -6305,19 +7455,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6330,8 +7486,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6339,8 +7495,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6399,7 +7555,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7583,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6421,7 +7594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeUrl>; /** @@ -6432,7 +7605,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6443,7 +7616,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeUrl>; createUrlAttribute( @@ -6453,18 +7626,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -6478,7 +7651,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -6487,7 +7660,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -6544,7 +7717,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6555,8 +7746,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. @@ -6566,8 +7757,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeUrl>; /** * Update an url attribute. Changing the `default` value will not update already existing documents. @@ -6577,8 +7768,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6588,8 +7779,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeUrl>; updateUrlAttribute( paramsOrFirst: @@ -6598,19 +7789,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6623,8 +7820,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6632,8 +7829,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6692,7 +7889,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6704,7 +7919,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6717,7 +7932,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeVarchar>; @@ -6730,7 +7945,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6743,7 +7958,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeVarchar>; @@ -6755,7 +7970,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6765,7 +7980,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6776,7 +7991,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6792,7 +8007,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6803,7 +8018,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6872,7 +8087,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6883,9 +8116,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the varchar attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the varchar attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. @@ -6895,9 +8128,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeVarchar>; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -6907,9 +8140,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the varchar attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the varchar attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6919,9 +8152,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeVarchar>; updateVarcharAttribute( paramsOrFirst: @@ -6930,21 +8163,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeVarchar> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6957,9 +8197,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6967,9 +8207,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7032,7 +8272,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8664,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7416,8 +8703,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. @@ -7431,8 +8718,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -7441,8 +8728,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7454,8 +8741,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7467,8 +8754,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -7478,8 +8765,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -7490,8 +8777,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -7507,8 +8794,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -7519,8 +8806,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -7576,7 +8863,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7585,7 +8890,7 @@ export class Databases { * @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. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. @@ -7596,7 +8901,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7604,7 +8909,7 @@ export class Databases { * @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. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7613,7 +8918,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; createDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7621,16 +8926,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7642,14 +8947,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7694,7 +8999,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7704,7 +9038,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. @@ -7715,7 +9049,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7724,7 +9058,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7733,7 +9067,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7741,16 +9075,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7762,14 +9096,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7814,7 +9148,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7824,7 +9187,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. @@ -7836,7 +9199,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7845,7 +9208,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7855,7 +9218,7 @@ export class Databases { collectionId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; updateDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7864,17 +9227,17 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7887,7 +9250,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -7895,7 +9258,7 @@ export class Databases { 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 | null, }; } @@ -7939,7 +9302,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9444,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9603,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8192,8 +9631,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. @@ -8208,8 +9647,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -8218,8 +9657,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8232,8 +9671,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; upsertDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8245,8 +9684,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8256,8 +9695,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8268,8 +9707,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8285,8 +9724,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8297,8 +9736,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8352,7 +9791,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8362,8 +9819,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. @@ -8378,8 +9835,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -8388,8 +9845,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8402,8 +9859,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; updateDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8415,8 +9872,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8426,8 +9883,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8438,8 +9895,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8455,8 +9912,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8467,8 +9924,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8522,7 +9979,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8650,8 +10125,8 @@ export class Databases { * @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.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. + * @param {number | null} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. @@ -8664,8 +10139,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Decrement a specific attribute of a document by a given value. @@ -8675,8 +10150,8 @@ export class Databases { * @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} 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. + * @param {number | null} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8689,8 +10164,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Document>; decrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8702,11 +10177,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8714,8 +10196,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -8729,8 +10211,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8739,8 +10221,8 @@ export class Databases { 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, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8798,7 +10280,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8809,8 +10309,8 @@ export class Databases { * @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. + * @param {number | null} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. @@ -8823,8 +10323,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Increment a specific attribute of a document by a given value. @@ -8834,8 +10334,8 @@ export class Databases { * @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. + * @param {number | null} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8848,8 +10348,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Document>; incrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8861,11 +10361,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8873,8 +10380,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -8888,8 +10395,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8898,8 +10405,8 @@ export class Databases { 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, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8957,7 +10464,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,12 +10592,42 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9096,7 +10651,7 @@ export class Databases { }): Promise<Models.Index>; /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9234,7 +10789,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10898,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..8d1f7f6 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,69 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class DocumentsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class DocumentsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class DocumentsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1384,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -988,7 +1396,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1000,7 +1408,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -1013,7 +1421,7 @@ export class DocumentsDB { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -1025,7 +1433,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1035,7 +1443,7 @@ export class DocumentsDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1046,7 +1454,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1062,7 +1470,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1073,7 +1481,7 @@ export class DocumentsDB { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1136,7 +1544,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1660,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1848,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2097,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2295,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2430,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2578,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2731,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2872,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +3030,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3217,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3404,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3696,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3872,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3999,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4195,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4303,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3570,33 +4419,33 @@ export class DocumentsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3605,12 +4454,12 @@ export class DocumentsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3637,7 +4486,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4646,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4733,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4817,51 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..12834f0 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,62 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + domains: [], + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +199,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +334,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +443,35 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + prices: [], + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +524,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +699,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +803,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +904,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +1000,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1091,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1185,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1276,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1370,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1461,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1555,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1646,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1740,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1829,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1923,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2031,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2193,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2359,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2510,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2676,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2829,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2999,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3150,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3316,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3473,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3635,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3786,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3952,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4124,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4303,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4454,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4622,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4822,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5066,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5216,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5384,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5485,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5659,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5760,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5906,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..baf425d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,32 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + embeddings: [], + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..1081725 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,78 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + functions: [], + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +179,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +196,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -150,6 +223,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise<Models.Function>; /** * 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. @@ -159,7 +233,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +250,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +278,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise<Models.Function>; create( paramsOrFirst: @@ -229,6 +305,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +330,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise<Models.Function> { let params: { @@ -278,6 +356,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +387,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +413,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +439,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +521,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +532,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +643,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + runtimes: [], + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + supports: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +741,33 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +822,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +893,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -640,15 +901,17 @@ export class Functions { * @param {string} params.commands - Build Commands. * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the function deployments. - * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} params.buildSpecification - Build specification for the function deployments. + * @param {string | null} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} params.emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -666,15 +929,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }): Promise<Models.Function>; /** * Update function by its unique ID. @@ -684,7 +949,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -692,15 +957,17 @@ export class Functions { * @param {string} commands - Build Commands. * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the function deployments. - * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} buildSpecification - Build specification for the function deployments. + * @param {string | null} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -719,15 +986,17 @@ export class Functions { commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, - runtimeSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, + runtimeSpecification?: string | null, deploymentRetention?: number, + interval?: number | null, + emailEnabled?: boolean | null, ): Promise<Models.Function>; update( paramsOrFirst: @@ -745,15 +1014,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; } | string, ...rest: [ @@ -769,15 +1040,17 @@ export class Functions { string?, ProjectKeyScopes[]?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, number?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.Function> { let params: { @@ -794,15 +1067,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; if ( @@ -824,15 +1099,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; } else { params = { @@ -849,15 +1126,17 @@ export class Functions { commands: rest[9] as string, scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, + providerRepositoryId: rest[12] as string | null, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - providerBranches: rest[16] as string[], - providerPaths: rest[17] as string[], - buildSpecification: rest[18] as string, - runtimeSpecification: rest[19] as string, + providerBranches: rest[16] as string[] | null, + providerPaths: rest[17] as string[] | null, + buildSpecification: rest[18] as string | null, + runtimeSpecification: rest[19] as string | null, deploymentRetention: rest[20] as number, + interval: rest[21] as number | null, + emailEnabled: rest[22] as boolean | null, }; } @@ -883,6 +1162,8 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; + const emailEnabled = params.emailEnabled; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1240,12 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof emailEnabled !== 'undefined') { + apiPayload['emailEnabled'] = emailEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1254,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1446,67 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1610,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1905,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2115,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2269,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2382,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2686,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2807,59 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2871,7 @@ export class Functions { * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ @@ -2190,7 +2882,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Execution>; /** * 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. @@ -2201,7 +2893,7 @@ export class Functions { * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2213,7 +2905,7 @@ export class Functions { xpath?: string, method?: ExecutionMethod, headers?: object, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Execution>; createExecution( paramsOrFirst: @@ -2224,7 +2916,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; } | string, ...rest: [ @@ -2233,7 +2925,7 @@ export class Functions { string?, ExecutionMethod?, object?, - string?, + (string | null)?, ] ): Promise<Models.Execution> { let params: { @@ -2243,7 +2935,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -2258,7 +2950,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -2268,7 +2960,7 @@ 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 | null, }; } @@ -2315,7 +3007,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3121,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3317,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3475,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3567,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2752,27 +3594,27 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2780,28 +3622,33 @@ export class Functions { updateVariable( functionId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2812,17 +3659,17 @@ export class Functions { params = (paramsOrFirst || {}) as { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2862,7 +3709,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..ca069ee 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + localeCodes: [], + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +170,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + continents: [], + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +245,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +320,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +397,32 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + phones: [], + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +473,36 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + currencies: [], + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +553,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + languages: [], + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..4ea6d8c 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,39 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + messages: [], + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,12 +137,12 @@ export class Messaging { * @param {string[]} params.targets - List of Targets IDs. * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -118,12 +155,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }): Promise<Models.Message>; /** * Create a new email message. @@ -136,12 +173,12 @@ export class Messaging { * @param {string[]} targets - List of Targets IDs. * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -155,12 +192,12 @@ export class Messaging { targets?: string[], cc?: string[], bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, + attachments?: string[] | null, draft?: boolean, html?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, + replyToEmail?: string, + replyToName?: string, ): Promise<Models.Message>; createEmail( paramsOrFirst: @@ -173,12 +210,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -189,11 +226,11 @@ export class Messaging { string[]?, string[]?, string[]?, - string[]?, - string?, - string?, + (string[] | null)?, boolean?, boolean?, + (string | null)?, + string?, string?, ] ): Promise<Models.Message> { @@ -206,12 +243,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -228,12 +265,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -245,12 +282,12 @@ export class Messaging { targets: rest[4] as string[], cc: rest[5] as string[], bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + attachments: rest[7] as string[] | null, + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string | null, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -263,11 +300,11 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; - const replyToEmail = params.replyToEmail; - const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -312,12 +349,6 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } - if (typeof replyToEmail !== 'undefined') { - apiPayload['replyToEmail'] = replyToEmail; - } - if (typeof replyToName !== 'undefined') { - apiPayload['replyToName'] = replyToName; - } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -327,6 +358,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -335,7 +372,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,126 +401,126 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.subject - Email Subject. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {string[]} params.cc - Array of target IDs to be added as CC. - * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} params.draft - Is message a draft - * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.subject - Email Subject. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {boolean | null} params.html - Is content of type HTML + * @param {string[] | null} params.cc - Array of target IDs to be added as CC. + * @param {string[] | null} params.bcc - Array of target IDs to be added as BCC. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.Message>; /** * 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} subject - Email Subject. - * @param {string} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {string[]} cc - Array of target IDs to be added as CC. - * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} draft - Is message a draft - * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} subject - Email Subject. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {boolean | null} html - Is content of type HTML + * @param {string[] | null} cc - Array of target IDs to be added as CC. + * @param {string[] | null} bcc - Array of target IDs to be added as BCC. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateEmail( messageId: string, - subject?: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - cc?: string[], - bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, - draft?: boolean, - html?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + subject?: string | null, + content?: string | null, + draft?: boolean | null, + html?: boolean | null, + cc?: string[] | null, + bcc?: string[] | null, + scheduledAt?: string | null, + attachments?: string[] | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.Message>; updateEmail( paramsOrFirst: | { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string?, - string?, - boolean?, - boolean?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.Message> { let params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -472,53 +530,53 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - subject: rest[0] as string, - content: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - cc: rest[5] as string[], - bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + subject: rest[3] as string | null, + content: rest[4] as string | null, + draft: rest[5] as boolean | null, + html: rest[6] as boolean | null, + cc: rest[7] as string[] | null, + bcc: rest[8] as string[] | null, + scheduledAt: rest[9] as string | null, + attachments: rest[10] as string[] | null, + replyToEmail: rest[11] as string | null, + replyToName: rest[12] as string | null, }; } const messageId = params.messageId; - const subject = params.subject; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; const cc = params.cc; const bcc = params.bcc; + const scheduledAt = params.scheduledAt; const attachments = params.attachments; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - const draft = params.draft; - const html = params.html; - const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -529,12 +587,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof subject !== 'undefined') { - apiPayload['subject'] = subject; - } - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -544,12 +596,27 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof subject !== 'undefined') { + apiPayload['subject'] = subject; + } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + if (typeof draft !== 'undefined') { + apiPayload['draft'] = draft; + } + if (typeof html !== 'undefined') { + apiPayload['html'] = html; + } if (typeof cc !== 'undefined') { apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { apiPayload['bcc'] = bcc; } + if (typeof scheduledAt !== 'undefined') { + apiPayload['scheduledAt'] = scheduledAt; + } if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } @@ -559,15 +626,6 @@ export class Messaging { if (typeof replyToName !== 'undefined') { apiPayload['replyToName'] = replyToName; } - if (typeof draft !== 'undefined') { - apiPayload['draft'] = draft; - } - if (typeof html !== 'undefined') { - apiPayload['html'] = html; - } - if (typeof scheduledAt !== 'undefined') { - apiPayload['scheduledAt'] = scheduledAt; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -576,7 +634,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -588,7 +667,7 @@ export class Messaging { * @param {string[]} params.topics - List of Topic IDs. * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional key-value pair data for push notification. + * @param {object | null} params.data - Additional key-value pair data for push notification. * @param {string} params.action - Action for push notification. * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. @@ -597,7 +676,7 @@ export class Messaging { * @param {string} params.tag - Tag for push notification. Available only for Android Platform. * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -612,7 +691,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -621,7 +700,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -636,7 +715,7 @@ export class Messaging { * @param {string[]} topics - List of Topic IDs. * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional key-value pair data for push notification. + * @param {object | null} data - Additional key-value pair data for push notification. * @param {string} action - Action for push notification. * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. @@ -645,7 +724,7 @@ export class Messaging { * @param {string} tag - Tag for push notification. Available only for Android Platform. * @param {number} badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -661,7 +740,7 @@ export class Messaging { topics?: string[], users?: string[], targets?: string[], - data?: object, + data?: object | null, action?: string, image?: string, icon?: string, @@ -670,7 +749,7 @@ export class Messaging { tag?: string, badge?: number, draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, @@ -685,7 +764,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -694,7 +773,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -707,7 +786,7 @@ export class Messaging { string[]?, string[]?, string[]?, - object?, + (object | null)?, string?, string?, string?, @@ -716,7 +795,7 @@ export class Messaging { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, MessagePriority?, @@ -730,7 +809,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -739,7 +818,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -758,7 +837,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -767,7 +846,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -781,7 +860,7 @@ export class Messaging { topics: rest[2] as string[], users: rest[3] as string[], targets: rest[4] as string[], - data: rest[5] as object, + data: rest[5] as object | null, action: rest[6] as string, image: rest[7] as string, icon: rest[8] as string, @@ -790,7 +869,7 @@ export class Messaging { tag: rest[11] as string, badge: rest[12] as number, draft: rest[13] as boolean, - scheduledAt: rest[14] as string, + scheduledAt: rest[14] as string | null, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, @@ -893,7 +972,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -901,168 +1001,168 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.title - Title for push notification. - * @param {string} params.body - Body for push notification. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional Data for push notification. - * @param {string} params.action - Action for push notification. - * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} params.color - Color for push notification. Available only for Android platforms. - * @param {string} params.tag - Tag for push notification. Available only for Android platforms. - * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.title - Title for push notification. + * @param {string | null} params.body - Body for push notification. + * @param {object | null} params.data - Additional Data for push notification. + * @param {string | null} params.action - Action for push notification. + * @param {string | null} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} params.color - Color for push notification. Available only for Android platforms. + * @param {string | null} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }): Promise<Models.Message>; /** * 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} title - Title for push notification. - * @param {string} body - Body for push notification. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional Data for push notification. - * @param {string} action - Action for push notification. - * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} color - Color for push notification. Available only for Android platforms. - * @param {string} tag - Tag for push notification. Available only for Android platforms. - * @param {number} badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} title - Title for push notification. + * @param {string | null} body - Body for push notification. + * @param {object | null} data - Additional Data for push notification. + * @param {string | null} action - Action for push notification. + * @param {string | null} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} color - Color for push notification. Available only for Android platforms. + * @param {string | null} tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePush( 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, - channelId?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + title?: string | null, + body?: string | null, + data?: object | null, + action?: string | null, + image?: string | null, + icon?: string | null, + sound?: string | null, + color?: string | null, + tag?: string | null, + badge?: number | null, + draft?: boolean | null, + scheduledAt?: string | null, + contentAvailable?: boolean | null, + critical?: boolean | null, + priority?: MessagePriority | null, + channelId?: string | null, ): Promise<Models.Message>; updatePush( 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - object?, - string?, - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string?, - boolean?, - boolean?, - MessagePriority?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (object | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (MessagePriority | null)?, + (string | null)?, ] ): Promise<Models.Message> { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; if ( @@ -1072,57 +1172,57 @@ export class Messaging { ) { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - title: rest[0] as string, - body: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - data: rest[5] as object, - action: rest[6] as string, - image: rest[7] as string, - icon: rest[8] as string, - sound: rest[9] as string, - color: rest[10] as string, - tag: rest[11] as string, - badge: rest[12] as number, - draft: rest[13] as boolean, - scheduledAt: rest[14] as string, - contentAvailable: rest[15] as boolean, - critical: rest[16] as boolean, - priority: rest[17] as MessagePriority, - channelId: rest[18] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + title: rest[3] as string | null, + body: rest[4] as string | null, + data: rest[5] as object | null, + action: rest[6] as string | null, + image: rest[7] as string | null, + icon: rest[8] as string | null, + sound: rest[9] as string | null, + color: rest[10] as string | null, + tag: rest[11] as string | null, + badge: rest[12] as number | null, + draft: rest[13] as boolean | null, + scheduledAt: rest[14] as string | null, + contentAvailable: rest[15] as boolean | null, + critical: rest[16] as boolean | null, + priority: rest[17] as MessagePriority | null, + channelId: rest[18] as string | null, }; } const messageId = params.messageId; - const title = params.title; - const body = params.body; const topics = params.topics; const users = params.users; const targets = params.targets; + const title = params.title; + const body = params.body; const data = params.data; const action = params.action; const image = params.image; @@ -1147,12 +1247,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof title !== 'undefined') { - apiPayload['title'] = title; - } - if (typeof body !== 'undefined') { - apiPayload['body'] = body; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1162,6 +1256,12 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof title !== 'undefined') { + apiPayload['title'] = title; + } + if (typeof body !== 'undefined') { + apiPayload['body'] = body; + } if (typeof data !== 'undefined') { apiPayload['data'] = data; } @@ -1212,7 +1312,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1224,7 +1345,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. @@ -1236,7 +1357,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1247,7 +1368,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1259,7 +1380,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSms( paramsOrFirst: @@ -1270,10 +1391,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1282,7 +1410,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1297,7 +1425,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1307,7 +1435,7 @@ 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 | null, }; } @@ -1359,7 +1487,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1371,7 +1520,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -1382,7 +1531,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1393,7 +1542,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1405,7 +1554,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSMS( paramsOrFirst: @@ -1416,10 +1565,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1428,7 +1584,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1443,7 +1599,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1453,7 +1609,7 @@ 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 | null, }; } @@ -1505,7 +1661,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1513,71 +1690,78 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ updateSms(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSms( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSms( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1587,30 +1771,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1623,9 +1807,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1635,6 +1816,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1649,7 +1833,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1657,70 +1862,77 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSMS(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSMS( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSMS( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1730,30 +1942,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1766,9 +1978,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1778,6 +1987,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1792,7 +2004,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2082,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2240,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2349,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + providers: [], + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2078,7 +2392,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. @@ -2091,7 +2405,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2103,7 +2417,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2116,7 +2430,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createApnsProvider( paramsOrFirst: @@ -2128,7 +2442,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2138,7 +2452,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2149,7 +2463,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2165,7 +2479,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2176,7 +2490,7 @@ 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 | null, }; } @@ -2230,7 +2544,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2243,7 +2576,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -2255,7 +2588,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2267,7 +2600,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2280,7 +2613,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createAPNSProvider( paramsOrFirst: @@ -2292,7 +2625,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2302,7 +2635,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2313,7 +2646,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2329,7 +2662,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2340,7 +2673,7 @@ 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 | null, }; } @@ -2394,7 +2727,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2402,12 +2754,12 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. @@ -2415,24 +2767,24 @@ export class Messaging { updateApnsProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2440,45 +2792,45 @@ export class Messaging { updateApnsProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateApnsProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2489,23 +2841,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2556,7 +2908,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2564,36 +2935,36 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAPNSProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2601,45 +2972,45 @@ export class Messaging { updateAPNSProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateAPNSProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2650,23 +3021,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2717,7 +3088,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2725,27 +3115,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createAppwriteProvider(params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Create a new Appwrite push provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2753,28 +3143,33 @@ export class Messaging { createAppwriteProvider( providerId: string, name: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; createAppwriteProvider( paramsOrFirst: | { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2785,17 +3180,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2837,7 +3232,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,27 +3259,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAppwriteProvider(params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Update an Appwrite push provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2873,28 +3287,33 @@ export class Messaging { updateAppwriteProvider( providerId: string, name?: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; updateAppwriteProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2905,17 +3324,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2954,7 +3373,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2962,8 +3400,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. @@ -2971,16 +3409,16 @@ export class Messaging { createFcmProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2988,25 +3426,25 @@ export class Messaging { createFcmProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFcmProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3017,15 +3455,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3063,7 +3501,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3071,24 +3528,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFCMProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3096,25 +3553,25 @@ export class Messaging { createFCMProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFCMProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3125,15 +3582,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3171,7 +3628,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,8 +3655,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. @@ -3188,16 +3664,16 @@ export class Messaging { updateFcmProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3205,25 +3681,25 @@ export class Messaging { updateFcmProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFcmProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3234,15 +3710,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3277,7 +3753,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3285,24 +3780,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFCMProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3310,25 +3805,25 @@ export class Messaging { updateFCMProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFCMProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3339,15 +3834,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3382,7 +3877,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3392,12 +3906,12 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.isEuRegion - Set as EU region. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3406,12 +3920,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Mailgun provider. @@ -3420,12 +3934,12 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean | null} isEuRegion - Set as EU region. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3435,12 +3949,12 @@ export class Messaging { name: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, + isEuRegion?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMailgunProvider( paramsOrFirst: @@ -3449,24 +3963,24 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -3474,12 +3988,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3492,12 +4006,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3505,12 +4019,12 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, + isEuRegion: rest[3] as boolean | null, fromName: rest[4] as string, 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 | null, }; } @@ -3572,7 +4086,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3582,8 +4115,8 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3596,8 +4129,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3610,8 +4143,8 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} isEuRegion - Set as EU region. + * @param {boolean | null} enabled - Set as enabled. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3625,8 +4158,8 @@ export class Messaging { name?: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, - enabled?: boolean, + isEuRegion?: boolean | null, + enabled?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, @@ -3639,8 +4172,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3651,8 +4184,8 @@ export class Messaging { string?, string?, string?, - boolean?, - boolean?, + (boolean | null)?, + (boolean | null)?, string?, string?, string?, @@ -3664,8 +4197,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3682,8 +4215,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3695,8 +4228,8 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, - enabled: rest[4] as boolean, + isEuRegion: rest[3] as boolean | null, + enabled: rest[4] as boolean | null, fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, @@ -3759,7 +4292,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3770,7 +4322,7 @@ export class Messaging { * @param {string} params.templateId - Msg91 template ID * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3780,7 +4332,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new MSG91 provider. @@ -3790,7 +4342,7 @@ export class Messaging { * @param {string} templateId - Msg91 template ID * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3801,7 +4353,7 @@ export class Messaging { templateId?: string, senderId?: string, authKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMsg91Provider( paramsOrFirst: @@ -3811,10 +4363,10 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -3822,7 +4374,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3836,7 +4388,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3845,7 +4397,7 @@ 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 | null, }; } @@ -3891,7 +4443,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3899,7 +4470,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.templateId - Msg91 template ID. * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. @@ -3909,7 +4480,7 @@ export class Messaging { updateMsg91Provider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3919,7 +4490,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} templateId - Msg91 template ID. * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. @@ -3930,7 +4501,7 @@ export class Messaging { updateMsg91Provider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, templateId?: string, senderId?: string, authKey?: string, @@ -3940,18 +4511,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3965,7 +4536,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3974,7 +4545,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, templateId: rest[2] as string, senderId: rest[3] as string, authKey: rest[4] as string, @@ -4020,7 +4591,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4033,7 +4623,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4045,7 +4635,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Resend provider. @@ -4057,7 +4647,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4070,7 +4660,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createResendProvider( paramsOrFirst: @@ -4082,7 +4672,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4092,7 +4682,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4103,7 +4693,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4119,7 +4709,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4130,7 +4720,7 @@ 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 | null, }; } @@ -4184,7 +4774,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4192,7 +4801,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Resend API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4204,7 +4813,7 @@ export class Messaging { updateResendProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4216,7 +4825,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Resend API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4229,7 +4838,7 @@ export class Messaging { updateResendProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4241,7 +4850,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4251,7 +4860,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4262,7 +4871,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4278,7 +4887,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4289,7 +4898,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4345,7 +4954,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4358,7 +4986,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4370,7 +4998,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Sendgrid provider. @@ -4382,7 +5010,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4395,7 +5023,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSendgridProvider( paramsOrFirst: @@ -4407,7 +5035,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4417,7 +5045,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4428,7 +5056,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4444,7 +5072,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4455,7 +5083,7 @@ 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 | null, }; } @@ -4509,7 +5137,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4517,7 +5164,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Sendgrid API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4529,7 +5176,7 @@ export class Messaging { updateSendgridProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4541,7 +5188,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Sendgrid API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4554,7 +5201,7 @@ export class Messaging { updateSendgridProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4566,7 +5213,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4576,7 +5223,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4587,7 +5234,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4603,7 +5250,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4614,7 +5261,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4670,7 +5317,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4685,7 +5351,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4699,7 +5365,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Amazon SES provider. @@ -4713,7 +5379,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4728,7 +5394,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSesProvider( paramsOrFirst: @@ -4742,7 +5408,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4754,7 +5420,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4767,7 +5433,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4785,7 +5451,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4798,7 +5464,7 @@ 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 | null, }; } @@ -4860,7 +5526,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4868,7 +5553,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accessKey - AWS access key ID. * @param {string} params.secretKey - AWS secret access key. * @param {string} params.region - AWS region, for example us-east-1. @@ -4882,7 +5567,7 @@ export class Messaging { updateSesProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4896,7 +5581,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accessKey - AWS access key ID. * @param {string} secretKey - AWS secret access key. * @param {string} region - AWS region, for example us-east-1. @@ -4911,7 +5596,7 @@ export class Messaging { updateSesProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accessKey?: string, secretKey?: string, region?: string, @@ -4925,7 +5610,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4937,7 +5622,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4950,7 +5635,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4968,7 +5653,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4981,7 +5666,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accessKey: rest[2] as string, secretKey: rest[3] as string, region: rest[4] as string, @@ -5047,7 +5732,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5066,7 +5770,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. @@ -5085,7 +5789,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5103,7 +5807,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5122,7 +5826,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSmtpProvider( paramsOrFirst: @@ -5140,7 +5844,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5156,7 +5860,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5173,7 +5877,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5195,7 +5899,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5212,7 +5916,7 @@ 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 | null, }; } @@ -5293,7 +5997,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5312,7 +6035,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5330,7 +6053,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5348,7 +6071,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5367,7 +6090,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSMTPProvider( paramsOrFirst: @@ -5385,7 +6108,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5401,7 +6124,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5418,7 +6141,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5440,7 +6163,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5457,7 +6180,7 @@ 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 | null, }; } @@ -5538,7 +6261,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5547,17 +6289,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. @@ -5566,17 +6308,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5584,17 +6326,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5603,17 +6345,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSmtpProvider( paramsOrFirst: @@ -5621,50 +6363,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5676,34 +6418,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -5778,7 +6520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5787,17 +6548,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5805,17 +6566,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5823,17 +6584,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5842,17 +6603,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSMTPProvider( paramsOrFirst: @@ -5860,50 +6621,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5915,34 +6676,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -6017,7 +6778,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6028,7 +6808,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6038,7 +6818,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Telesign provider. @@ -6048,7 +6828,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6059,7 +6839,7 @@ export class Messaging { from?: string, customerId?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTelesignProvider( paramsOrFirst: @@ -6069,10 +6849,10 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6080,7 +6860,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6094,7 +6874,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6103,7 +6883,7 @@ 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 | null, }; } @@ -6149,7 +6929,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6157,7 +6956,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. * @param {string} params.from - Sender number. @@ -6167,7 +6966,7 @@ export class Messaging { updateTelesignProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6177,7 +6976,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. * @param {string} from - Sender number. @@ -6188,7 +6987,7 @@ export class Messaging { updateTelesignProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, customerId?: string, apiKey?: string, from?: string, @@ -6198,18 +6997,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6223,7 +7022,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6232,7 +7031,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, customerId: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6278,7 +7077,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6289,7 +7107,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6299,7 +7117,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Textmagic provider. @@ -6309,7 +7127,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6320,7 +7138,7 @@ export class Messaging { from?: string, username?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTextmagicProvider( paramsOrFirst: @@ -6330,10 +7148,10 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6341,7 +7159,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6355,7 +7173,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6364,7 +7182,7 @@ 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 | null, }; } @@ -6410,7 +7228,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6418,7 +7255,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. * @param {string} params.from - Sender number. @@ -6428,7 +7265,7 @@ export class Messaging { updateTextmagicProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6438,7 +7275,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. * @param {string} from - Sender number. @@ -6449,7 +7286,7 @@ export class Messaging { updateTextmagicProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, username?: string, apiKey?: string, from?: string, @@ -6459,18 +7296,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6484,7 +7321,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6493,7 +7330,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, username: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6539,7 +7376,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6550,7 +7406,7 @@ export class Messaging { * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6560,7 +7416,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Twilio provider. @@ -6570,7 +7426,7 @@ export class Messaging { * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6581,7 +7437,7 @@ export class Messaging { from?: string, accountSid?: string, authToken?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTwilioProvider( paramsOrFirst: @@ -6591,10 +7447,10 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6602,7 +7458,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6616,7 +7472,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6625,7 +7481,7 @@ 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 | null, }; } @@ -6671,7 +7527,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6679,7 +7554,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6689,7 +7564,7 @@ export class Messaging { updateTwilioProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6699,7 +7574,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6710,7 +7585,7 @@ export class Messaging { updateTwilioProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accountSid?: string, authToken?: string, from?: string, @@ -6720,18 +7595,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6745,7 +7620,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6754,7 +7629,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accountSid: rest[2] as string, authToken: rest[3] as string, from: rest[4] as string, @@ -6800,7 +7675,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6811,7 +7705,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6821,7 +7715,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Vonage provider. @@ -6831,7 +7725,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6842,7 +7736,7 @@ export class Messaging { from?: string, apiKey?: string, apiSecret?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createVonageProvider( paramsOrFirst: @@ -6852,10 +7746,10 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6863,7 +7757,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6877,7 +7771,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6886,7 +7780,7 @@ 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 | null, }; } @@ -6932,7 +7826,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6940,7 +7853,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. * @param {string} params.from - Sender number. @@ -6950,7 +7863,7 @@ export class Messaging { updateVonageProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -6960,7 +7873,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. * @param {string} from - Sender number. @@ -6971,7 +7884,7 @@ export class Messaging { updateVonageProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, apiSecret?: string, from?: string, @@ -6981,18 +7894,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7006,7 +7919,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7015,7 +7928,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, apiSecret: rest[3] as string, from: rest[4] as string, @@ -7061,7 +7974,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +8050,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8204,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + topics: [], + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7262,8 +8243,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ @@ -7271,8 +8252,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Create a new topic. @@ -7280,8 +8261,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7290,8 +8271,8 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, - expiry?: number, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; createTopic( paramsOrFirst: @@ -7299,18 +8280,18 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [string?, string[]?, (number | null)?, (number | null)?] ): Promise<Models.Topic> { let params: { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7322,16 +8303,16 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7373,7 +8354,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7438,58 +8457,63 @@ export class Messaging { * * * @param {string} params.topicId - Topic ID. - * @param {string} params.name - Topic Name. - * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} params.name - Topic Name. + * @param {string[] | null} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Update a topic by its unique ID. * * * @param {string} topicId - Topic ID. - * @param {string} name - Topic Name. - * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} name - Topic Name. + * @param {string[] | null} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. */ updateTopic( topicId: string, - name?: string, - subscribe?: string[], - qos?: number, - expiry?: number, + name?: string | null, + subscribe?: string[] | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; updateTopic( paramsOrFirst: | { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [ + (string | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Topic> { let params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7499,18 +8523,18 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, - name: rest[0] as string, - subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + name: rest[0] as string | null, + subscribe: rest[1] as string[] | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7549,7 +8573,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8750,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + subscribers: [], + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8875,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8972,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..169782c 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,74 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mongo { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mongo { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mongo { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mongo { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mongo { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,40 +2620,59 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2045,12 +2681,12 @@ export class Mongo { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2077,7 +2713,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2861,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2177,21 +2925,21 @@ export class Mongo { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2199,18 +2947,22 @@ export class Mongo { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2221,13 +2973,13 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2263,7 +3015,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3175,37 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3262,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3332,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,35 +3477,78 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2633,28 +3556,45 @@ export class Mongo { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -2665,17 +3605,23 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -2684,6 +3630,9 @@ export class Mongo { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -2706,6 +3655,15 @@ export class Mongo { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2714,7 +3672,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3767,129 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mongo/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3944,52 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +4067,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..13e7de1 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,74 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mysql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mysql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mysql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mysql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Mysql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,40 +2747,68 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2153,12 +2817,12 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2185,7 +2849,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2997,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2285,21 +3061,21 @@ export class Mysql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2307,18 +3083,22 @@ export class Mysql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2329,13 +3109,13 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2371,7 +3151,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3311,37 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3398,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,97 +3468,118 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2689,26 +3589,26 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2763,7 +3663,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3741,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,35 +3886,78 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2972,28 +3965,45 @@ export class Mysql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3004,17 +4014,23 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3023,6 +4039,9 @@ export class Mysql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3045,6 +4064,15 @@ export class Mysql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3053,7 +4081,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4176,129 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mysql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4353,52 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4476,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..84e0c31 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -347,9 +377,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -365,9 +395,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -383,9 +413,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -402,9 +432,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -420,9 +450,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -436,9 +466,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, string?, ] @@ -453,9 +483,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -476,9 +506,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -493,9 +523,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2DeviceAuthorization>; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2DeviceAuthorization>; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise<Models.Oauth2DeviceAuthorization> { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + organizations: [], + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -999,9 +1140,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1016,9 +1157,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2PAR>; /** @@ -1033,9 +1174,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1051,9 +1192,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2PAR>; createPAR( @@ -1068,9 +1209,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1083,9 +1224,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, ] ): Promise<Models.Oauth2PAR> { @@ -1099,9 +1240,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1120,9 +1261,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1136,9 +1277,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1363,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1457,32 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1540,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1671,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1494,7 +1685,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2Token>; /** @@ -1508,7 +1699,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1523,7 +1714,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2Token>; createToken( @@ -1537,7 +1728,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1740,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise<Models.Oauth2Token> { @@ -1562,7 +1753,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1771,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1784,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1846,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..37dffa7 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +330,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,40 +407,64 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. */ updateInstallation( installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: - { installationId: string; authorizationDetails?: string } | string, - ...rest: [string?] + | { installationId: string; authorizationDetails?: string | null } + | string, + ...rest: [(string | null)?] ): Promise<Models.AppInstallation> { - let params: { installationId: string; authorizationDetails?: string }; + let params: { + installationId: string; + authorizationDetails?: string | null; + }; if ( paramsOrFirst && @@ -345,12 +473,12 @@ export class Organization { ) { params = (paramsOrFirst || {}) as { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string, + authorizationDetails: rest[0] as string | null, }; } @@ -377,7 +505,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +660,44 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +824,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +905,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1007,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1168,92 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1340,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1469,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1616,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1827,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1964,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2052,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1441,7 +2082,7 @@ export class Organization { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -1450,7 +2091,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -1459,7 +2100,7 @@ export class Organization { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1469,7 +2110,7 @@ export class Organization { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateProjectKey( paramsOrFirst: @@ -1478,17 +2119,17 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { projectId: string; keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -1501,7 +2142,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } else { params = { @@ -1509,7 +2150,7 @@ export class Organization { keyId: rest[0] as string, name: rest[1] as string, scopes: rest[2] as ProjectKeyScopes[], - expire: rest[3] as string, + expire: rest[3] as string | null, }; } @@ -1553,7 +2194,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..aafaf2d 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,74 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Postgresql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Postgresql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Postgresql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Postgresql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Postgresql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,7 +2747,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2834,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + metadata: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2937,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,40 +3070,96 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2365,12 +3168,12 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2397,7 +3200,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3348,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2497,21 +3412,21 @@ export class Postgresql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2519,18 +3434,22 @@ export class Postgresql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2541,13 +3460,13 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2583,7 +3502,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3662,37 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3749,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,97 +3819,118 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2901,26 +3940,26 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2975,7 +4014,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4092,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,35 +4237,78 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3184,28 +4316,45 @@ export class Postgresql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3216,17 +4365,23 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3235,6 +4390,9 @@ export class Postgresql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3257,6 +4415,15 @@ export class Postgresql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3265,7 +4432,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4527,129 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4704,52 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4827,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..edc7fe1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,35 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + presences: [], + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +176,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +330,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +493,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..6e554ab 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +148,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -81,7 +160,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -144,7 +223,719 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.ProjectList>; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise<Models.ProjectList>; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.ProjectList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + getEnvironment(params: { environmentId: string }): Promise<Models.Project>; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise<Models.Project>; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<Models.Project> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -209,7 +1000,38 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +1114,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +1185,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -352,7 +1214,7 @@ export class Project { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -360,7 +1222,7 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -368,7 +1230,7 @@ export class Project { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -377,7 +1239,7 @@ export class Project { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateKey( paramsOrFirst: @@ -385,16 +1247,16 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -406,14 +1268,14 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } 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 | null, }; } @@ -452,7 +1314,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +1440,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +1582,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + mockNumbers: [], + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1676,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1827,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1962,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + providers: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -945,16 +1985,16 @@ export class Project { * @param {string} params.authorizationUrl - URL to your application with consent screen. * @param {string[]} params.scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -965,16 +2005,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }): Promise<Models.Project>; @@ -985,16 +2025,16 @@ export class Project { * @param {string} authorizationUrl - URL to your application with consent screen. * @param {string[]} scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -1006,16 +2046,16 @@ export class Project { authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], - accessTokenDuration?: number, - refreshTokenDuration?: number, - publicAccessTokenDuration?: number, - publicRefreshTokenDuration?: number, - installationAccessTokenDuration?: number, - confidentialPkce?: boolean, + accessTokenDuration?: number | null, + refreshTokenDuration?: number | null, + publicAccessTokenDuration?: number | null, + publicRefreshTokenDuration?: number | null, + installationAccessTokenDuration?: number | null, + confidentialPkce?: boolean | null, verificationUrl?: string, - userCodeLength?: number, + userCodeLength?: number | null, userCodeFormat?: string, - deviceCodeDuration?: number, + deviceCodeDuration?: number | null, defaultScopes?: string[], installationScopes?: string[], ): Promise<Models.Project>; @@ -1026,16 +2066,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; } @@ -1044,16 +2084,16 @@ export class Project { string?, string[]?, string[]?, - number?, - number?, - number?, - number?, - number?, - boolean?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, string?, - number?, + (number | null)?, string?, - number?, + (number | null)?, string[]?, string[]?, ] @@ -1063,16 +2103,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1087,16 +2127,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1106,16 +2146,16 @@ export class Project { authorizationUrl: rest[0] as string, scopes: rest[1] as string[], authorizationDetailsTypes: rest[2] as string[], - accessTokenDuration: rest[3] as number, - refreshTokenDuration: rest[4] as number, - publicAccessTokenDuration: rest[5] as number, - publicRefreshTokenDuration: rest[6] as number, - installationAccessTokenDuration: rest[7] as number, - confidentialPkce: rest[8] as boolean, + accessTokenDuration: rest[3] as number | null, + refreshTokenDuration: rest[4] as number | null, + publicAccessTokenDuration: rest[5] as number | null, + publicRefreshTokenDuration: rest[6] as number | null, + installationAccessTokenDuration: rest[7] as number | null, + confidentialPkce: rest[8] as boolean | null, verificationUrl: rest[9] as string, - userCodeLength: rest[10] as number, + userCodeLength: rest[10] as number | null, userCodeFormat: rest[11] as string, - deviceCodeDuration: rest[12] as number, + deviceCodeDuration: rest[12] as number | null, defaultScopes: rest[13] as string[], installationScopes: rest[14] as string[], }; @@ -1208,48 +2248,127 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Amazon configuration. * - * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} */ updateOAuth2Amazon(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Amazon>; /** * Update the project OAuth2 Amazon configuration. * - * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Amazon( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Amazon>; updateOAuth2Amazon( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Amazon> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1259,15 +2378,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1293,76 +2412,99 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Apple configuration. * - * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} */ updateOAuth2Apple(params?: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Apple>; /** * Update the project OAuth2 Apple configuration. * - * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Apple( - serviceId?: string, - keyId?: string, - teamId?: string, - p8File?: string, - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + serviceId?: string | null, + keyId?: string | null, + teamId?: string | null, + p8File?: string | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Apple>; updateOAuth2Apple( paramsOrFirst?: | { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Apple> { let params: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -1372,23 +2514,23 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - serviceId: paramsOrFirst as string, - keyId: rest[0] as string, - teamId: rest[1] as string, - p8File: rest[2] as string, - nativeClientIds: rest[3] as string[], - enabled: rest[4] as boolean, - nativeEnabled: rest[5] as boolean, + serviceId: paramsOrFirst as string | null, + keyId: rest[0] as string | null, + teamId: rest[1] as string | null, + p8File: rest[2] as string | null, + enabled: rest[3] as boolean | null, + nativeClientIds: rest[4] as string[] | null, + nativeEnabled: rest[5] as boolean | null, }; } @@ -1396,8 +2538,8 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; @@ -1413,12 +2555,12 @@ export class Project { if (typeof p8File !== 'undefined') { apiPayload['p8File'] = p8File; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -1430,48 +2572,72 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} */ updateOAuth2Appwrite(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Appwrite>; /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Appwrite( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Appwrite>; updateOAuth2Appwrite( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Appwrite> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1481,15 +2647,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1515,64 +2681,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} */ updateOAuth2Auth0(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }): Promise<Models.OAuth2Auth0>; /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Auth0( - clientId?: string, - clientSecret?: string, - endpoint?: string, - prompt?: ProjectOAuth2Auth0Prompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2Auth0Prompt[] | null, ): Promise<Models.OAuth2Auth0>; updateOAuth2Auth0( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2Auth0Prompt[] | null)?, + ] ): Promise<Models.OAuth2Auth0> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; if ( @@ -1582,27 +2769,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - prompt: rest[2] as ProjectOAuth2Auth0Prompt[], - enabled: rest[3] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1614,12 +2801,12 @@ export class Project { if (typeof endpoint !== 'undefined') { apiPayload['endpoint'] = endpoint; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1628,58 +2815,76 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Authentik configuration. * - * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} */ updateOAuth2Authentik(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Authentik>; /** * Update the project OAuth2 Authentik configuration. * - * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Authentik( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Authentik>; updateOAuth2Authentik( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Authentik> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -1689,17 +2894,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -1729,48 +2934,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} */ updateOAuth2Autodesk(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Autodesk>; /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Autodesk( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Autodesk>; updateOAuth2Autodesk( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Autodesk> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1780,15 +3006,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1814,44 +3040,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} */ updateOAuth2Bitbucket(params?: { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitbucket>; /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitbucket( - key?: string, - secret?: string, - enabled?: boolean, + key?: string | null, + secret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitbucket>; updateOAuth2Bitbucket( paramsOrFirst?: - { key?: string; secret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitbucket> { - let params: { key?: string; secret?: string; enabled?: boolean }; + let params: { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -1860,15 +3111,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }; } else { params = { - key: paramsOrFirst as string, - secret: rest[0] as string, - enabled: rest[1] as boolean, + key: paramsOrFirst as string | null, + secret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1894,48 +3145,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitly configuration. * - * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} */ updateOAuth2Bitly(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitly>; /** * Update the project OAuth2 Bitly configuration. * - * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitly( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitly>; updateOAuth2Bitly( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitly> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1945,15 +3216,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1979,48 +3250,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Box configuration. * - * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} */ updateOAuth2Box(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Box>; /** * Update the project OAuth2 Box configuration. * - * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Box( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Box>; updateOAuth2Box( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Box> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2030,15 +3321,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2064,48 +3355,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} */ updateOAuth2Cloudflare(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Cloudflare>; /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Cloudflare( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Cloudflare>; updateOAuth2Cloudflare( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Cloudflare> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2115,15 +3426,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2149,44 +3460,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} */ updateOAuth2Dailymotion(params?: { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dailymotion>; /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dailymotion( - apiKey?: string, - apiSecret?: string, - enabled?: boolean, + apiKey?: string | null, + apiSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dailymotion>; updateOAuth2Dailymotion( paramsOrFirst?: - { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dailymotion> { - let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + let params: { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2195,15 +3531,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - apiKey: paramsOrFirst as string, - apiSecret: rest[0] as string, - enabled: rest[1] as boolean, + apiKey: paramsOrFirst as string | null, + apiSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2229,58 +3565,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Discord configuration. * - * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} */ updateOAuth2Discord(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }): Promise<Models.OAuth2Discord>; /** * Update the project OAuth2 Discord configuration. * - * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Discord( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2DiscordPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2DiscordPrompt[] | null, ): Promise<Models.OAuth2Discord>; updateOAuth2Discord( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2DiscordPrompt[] | null)?, + ] ): Promise<Models.OAuth2Discord> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; if ( @@ -2290,24 +3646,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2DiscordPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2316,12 +3672,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2330,48 +3686,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Disqus configuration. * - * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} */ updateOAuth2Disqus(params?: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Disqus>; /** * Update the project OAuth2 Disqus configuration. * - * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Disqus( - publicKey?: string, - secretKey?: string, - enabled?: boolean, + publicKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Disqus>; updateOAuth2Disqus( paramsOrFirst?: - | { publicKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Disqus> { let params: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -2381,15 +3758,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - publicKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + publicKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2415,44 +3792,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} */ updateOAuth2Dropbox(params?: { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dropbox>; /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dropbox( - appKey?: string, - appSecret?: string, - enabled?: boolean, + appKey?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dropbox>; updateOAuth2Dropbox( paramsOrFirst?: - { appKey?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dropbox> { - let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + let params: { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2461,15 +3863,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appKey: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appKey: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2495,48 +3897,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Etsy configuration. * - * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} */ updateOAuth2Etsy(params?: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Etsy>; /** * Update the project OAuth2 Etsy configuration. * - * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Etsy( - keyString?: string, - sharedSecret?: string, - enabled?: boolean, + keyString?: string | null, + sharedSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Etsy>; updateOAuth2Etsy( paramsOrFirst?: - | { keyString?: string; sharedSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Etsy> { let params: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2546,15 +3968,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - keyString: paramsOrFirst as string, - sharedSecret: rest[0] as string, - enabled: rest[1] as boolean, + keyString: paramsOrFirst as string | null, + sharedSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2580,44 +4002,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Facebook configuration. * - * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} */ updateOAuth2Facebook(params?: { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Facebook>; /** * Update the project OAuth2 Facebook configuration. * - * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Facebook( - appId?: string, - appSecret?: string, - enabled?: boolean, + appId?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Facebook>; updateOAuth2Facebook( paramsOrFirst?: - { appId?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Facebook> { - let params: { appId?: string; appSecret?: string; enabled?: boolean }; + let params: { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2626,15 +4073,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appId: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appId: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2660,48 +4107,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Figma configuration. * - * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} */ updateOAuth2Figma(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Figma>; /** * Update the project OAuth2 Figma configuration. * - * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Figma( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Figma>; updateOAuth2Figma( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Figma> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2711,15 +4178,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2745,58 +4212,74 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} */ updateOAuth2FusionAuth(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2FusionAuth>; /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2FusionAuth( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2FusionAuth>; updateOAuth2FusionAuth( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2FusionAuth> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -2806,17 +4289,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -2846,58 +4329,79 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 GitHub configuration. * - * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} */ updateOAuth2GitHub(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }): Promise<Models.OAuth2Github>; /** * Update the project OAuth2 GitHub configuration. * - * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2GitHub( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GitHubPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2GitHubPrompt[] | null, ): Promise<Models.OAuth2Github>; updateOAuth2GitHub( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2GitHubPrompt[] | null)?, + ] ): Promise<Models.OAuth2Github> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; if ( @@ -2907,24 +4411,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GitHubPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2933,12 +4437,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2947,58 +4451,75 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} */ updateOAuth2Gitlab(params?: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Gitlab>; /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Gitlab( - applicationId?: string, - secret?: string, - endpoint?: string, - enabled?: boolean, + applicationId?: string | null, + secret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Gitlab>; updateOAuth2Gitlab( paramsOrFirst?: | { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Gitlab> { let params: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -3008,17 +4529,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - applicationId: paramsOrFirst as string, - secret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + applicationId: paramsOrFirst as string | null, + secret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -3048,76 +4569,93 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Google configuration. * - * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} */ updateOAuth2Google(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Google>; /** * Update the project OAuth2 Google configuration. * - * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Google( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GooglePrompt[], - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + prompt?: ProjectOAuth2GooglePrompt[] | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Google>; updateOAuth2Google( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - ProjectOAuth2GooglePrompt[]?, - string[]?, - boolean?, - boolean?, + (string | null)?, + (ProjectOAuth2GooglePrompt[] | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Google> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -3127,29 +4665,29 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GooglePrompt[], - nativeClientIds: rest[2] as string[], - enabled: rest[3] as boolean, - nativeEnabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + prompt: rest[1] as ProjectOAuth2GooglePrompt[] | null, + enabled: rest[2] as boolean | null, + nativeClientIds: rest[3] as string[] | null, + nativeEnabled: rest[4] as boolean | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; @@ -3162,12 +4700,12 @@ export class Project { if (typeof prompt !== 'undefined') { apiPayload['prompt'] = prompt; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -3179,48 +4717,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Hugging Face configuration. * - * @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. + * @param {string | null} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} */ updateOAuth2HuggingFace(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2HuggingFace>; /** * 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. + * @param {string | null} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2HuggingFace( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2HuggingFace>; updateOAuth2HuggingFace( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2HuggingFace> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3230,15 +4791,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3264,58 +4825,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kakao configuration. * - * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} */ updateOAuth2Kakao(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }): Promise<Models.OAuth2Kakao>; /** * Update the project OAuth2 Kakao configuration. * - * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kakao( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2KakaoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2KakaoPrompt[] | null, ): Promise<Models.OAuth2Kakao>; updateOAuth2Kakao( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2KakaoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Kakao> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; if ( @@ -3325,24 +4906,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2KakaoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2KakaoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/kakao'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3351,12 +4932,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3365,64 +4946,86 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} */ updateOAuth2Keycloak(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Keycloak>; /** * Update the project OAuth2 Keycloak configuration. * - * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com - * @param {string} realmName - Keycloak realm name. For example: appwrite-realm - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Keycloak( - clientId?: string, - clientSecret?: string, - endpoint?: string, - realmName?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + realmName?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Keycloak>; updateOAuth2Keycloak( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Keycloak> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; if ( @@ -3432,19 +5035,19 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; } 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, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + realmName: rest[2] as string | null, + enabled: rest[3] as boolean | null, }; } @@ -3478,48 +5081,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kick configuration. * - * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} */ updateOAuth2Kick(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Kick>; /** * Update the project OAuth2 Kick configuration. * - * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kick( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Kick>; updateOAuth2Kick( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Kick> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3529,15 +5154,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3563,52 +5188,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} */ updateOAuth2Linkedin(params?: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Linkedin>; /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Linkedin( - clientId?: string, - primaryClientSecret?: string, - enabled?: boolean, + clientId?: string | null, + primaryClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Linkedin>; updateOAuth2Linkedin( paramsOrFirst?: | { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Linkedin> { let params: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3618,15 +5259,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + primaryClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3652,64 +5293,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} */ updateOAuth2Microsoft(params?: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }): Promise<Models.OAuth2Microsoft>; /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Microsoft( - applicationId?: string, - applicationSecret?: string, - tenant?: string, - prompt?: ProjectOAuth2MicrosoftPrompt[], - enabled?: boolean, + applicationId?: string | null, + applicationSecret?: string | null, + tenant?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2MicrosoftPrompt[] | null, ): Promise<Models.OAuth2Microsoft>; updateOAuth2Microsoft( paramsOrFirst?: | { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2MicrosoftPrompt[] | null)?, + ] ): Promise<Models.OAuth2Microsoft> { let params: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; if ( @@ -3719,27 +5381,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; } else { params = { - applicationId: paramsOrFirst as string, - applicationSecret: rest[0] as string, - tenant: rest[1] as string, - prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], - enabled: rest[3] as boolean, + applicationId: paramsOrFirst as string | null, + applicationSecret: rest[0] as string | null, + tenant: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[] | null, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3751,12 +5413,12 @@ export class Project { if (typeof tenant !== 'undefined') { apiPayload['tenant'] = tenant; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3765,52 +5427,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Notion configuration. * - * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} */ updateOAuth2Notion(params?: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Notion>; /** * Update the project OAuth2 Notion configuration. * - * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Notion( - oauthClientId?: string, - oauthClientSecret?: string, - enabled?: boolean, + oauthClientId?: string | null, + oauthClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Notion>; updateOAuth2Notion( paramsOrFirst?: | { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Notion> { let params: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3820,15 +5500,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauthClientId: paramsOrFirst as string, - oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauthClientId: paramsOrFirst as string | null, + oauthClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3854,97 +5534,113 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Oidc configuration. * - * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} */ updateOAuth2Oidc(params?: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Oidc>; /** * Update the project OAuth2 Oidc configuration. * - * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} * @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, + clientId?: string | null, + clientSecret?: string | null, + wellKnownURL?: string | null, + authorizationURL?: string | null, + tokenURL?: string | null, + userInfoURL?: string | null, + prompt?: ProjectOAuth2OidcPrompt[] | null, + maxAge?: number | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Oidc>; updateOAuth2Oidc( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - string?, - string?, - ProjectOAuth2OidcPrompt[]?, - number?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectOAuth2OidcPrompt[] | null)?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Oidc> { let params: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; if ( @@ -3954,27 +5650,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - wellKnownURL: rest[1] as string, - authorizationURL: rest[2] as string, - tokenURL: rest[3] as string, - userInfoURL: rest[4] as string, - prompt: rest[5] as ProjectOAuth2OidcPrompt[], - maxAge: rest[6] as number, - enabled: rest[7] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + wellKnownURL: rest[1] as string | null, + authorizationURL: rest[2] as string | null, + tokenURL: rest[3] as string | null, + userInfoURL: rest[4] as string | null, + prompt: rest[5] as ProjectOAuth2OidcPrompt[] | null, + maxAge: rest[6] as number | null, + enabled: rest[7] as boolean | null, }; } @@ -4024,76 +5720,97 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Okta configuration. * - * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} */ updateOAuth2Okta(params?: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }): Promise<Models.OAuth2Okta>; /** * Update the project OAuth2 Okta configuration. * - * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Okta( - clientId?: string, - clientSecret?: string, - domain?: string, - authorizationServerId?: string, - prompt?: ProjectOAuth2OktaPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + domain?: string | null, + authorizationServerId?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2OktaPrompt[] | null, ): Promise<Models.OAuth2Okta>; updateOAuth2Okta( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - ProjectOAuth2OktaPrompt[]?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2OktaPrompt[] | null)?, ] ): Promise<Models.OAuth2Okta> { let params: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; if ( @@ -4103,21 +5820,21 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - domain: rest[1] as string, - authorizationServerId: rest[2] as string, - prompt: rest[3] as ProjectOAuth2OktaPrompt[], - enabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + domain: rest[1] as string | null, + authorizationServerId: rest[2] as string | null, + enabled: rest[3] as boolean | null, + prompt: rest[4] as ProjectOAuth2OktaPrompt[] | null, }; } @@ -4125,8 +5842,8 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4141,12 +5858,12 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { apiPayload['authorizationServerId'] = authorizationServerId; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4155,48 +5872,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Paypal configuration. * - * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2Paypal(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 Paypal configuration. * - * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Paypal( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2Paypal( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4206,15 +5946,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4240,48 +5980,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2PaypalSandbox(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2PaypalSandbox( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2PaypalSandbox( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4291,15 +6051,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4325,48 +6085,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Podio configuration. * - * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} */ updateOAuth2Podio(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Podio>; /** * Update the project OAuth2 Podio configuration. * - * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Podio( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Podio>; updateOAuth2Podio( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Podio> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4376,15 +6156,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4410,48 +6190,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Resend configuration. * - * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} */ updateOAuth2Resend(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Resend>; /** * Update the project OAuth2 Resend configuration. * - * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Resend( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Resend>; updateOAuth2Resend( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Resend> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4461,15 +6261,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4495,58 +6295,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} */ updateOAuth2Salesforce(params?: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }): Promise<Models.OAuth2Salesforce>; /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Salesforce( - customerKey?: string, - customerSecret?: string, - prompt?: ProjectOAuth2SalesforcePrompt[], - enabled?: boolean, + customerKey?: string | null, + customerSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2SalesforcePrompt[] | null, ): Promise<Models.OAuth2Salesforce>; updateOAuth2Salesforce( paramsOrFirst?: | { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2SalesforcePrompt[] | null)?, + ] ): Promise<Models.OAuth2Salesforce> { let params: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; if ( @@ -4556,24 +6376,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; } else { params = { - customerKey: paramsOrFirst as string, - customerSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], - enabled: rest[2] as boolean, + customerKey: paramsOrFirst as string | null, + customerSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[] | null, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4582,12 +6402,12 @@ export class Project { if (typeof customerSecret !== 'undefined') { apiPayload['customerSecret'] = customerSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4596,48 +6416,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Slack configuration. * - * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} */ updateOAuth2Slack(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Slack>; /** * Update the project OAuth2 Slack configuration. * - * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Slack( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Slack>; updateOAuth2Slack( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Slack> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4647,15 +6488,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4681,48 +6522,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Spotify configuration. * - * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} */ updateOAuth2Spotify(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Spotify>; /** * Update the project OAuth2 Spotify configuration. * - * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Spotify( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Spotify>; updateOAuth2Spotify( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Spotify> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4732,15 +6593,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4766,48 +6627,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Stripe configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} */ updateOAuth2Stripe(params?: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Stripe>; /** * Update the project OAuth2 Stripe configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Stripe( - clientId?: string, - apiSecretKey?: string, - enabled?: boolean, + clientId?: string | null, + apiSecretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Stripe>; updateOAuth2Stripe( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Stripe> { let params: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4817,15 +6698,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + apiSecretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4851,48 +6732,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} */ updateOAuth2TikTok(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2TikTok>; /** * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TikTok( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2TikTok>; updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2TikTok> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4902,15 +6803,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4936,52 +6837,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2Tradeshift(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Tradeshift( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2Tradeshift( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4991,15 +6908,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5025,52 +6942,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2TradeshiftSandbox(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TradeshiftSandbox( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2TradeshiftSandbox( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5080,15 +7013,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5114,48 +7047,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Twitch configuration. * - * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} */ updateOAuth2Twitch(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Twitch>; /** * Update the project OAuth2 Twitch configuration. * - * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Twitch( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Twitch>; updateOAuth2Twitch( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Twitch> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5165,15 +7118,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5199,48 +7152,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Webflow configuration. * - * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} */ updateOAuth2Webflow(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Webflow>; /** * Update the project OAuth2 Webflow configuration. * - * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Webflow( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Webflow>; updateOAuth2Webflow( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Webflow> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5250,15 +7223,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5284,48 +7257,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 WordPress configuration. * - * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} */ updateOAuth2WordPress(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2WordPress>; /** * Update the project OAuth2 WordPress configuration. * - * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2WordPress( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2WordPress>; updateOAuth2WordPress( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2WordPress> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5335,15 +7328,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5369,48 +7362,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 X configuration. * - * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} */ updateOAuth2X(params?: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2X>; /** * Update the project OAuth2 X configuration. * - * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2X( - customerKey?: string, - secretKey?: string, - enabled?: boolean, + customerKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2X>; updateOAuth2X( paramsOrFirst?: - | { customerKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2X> { let params: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -5420,15 +7433,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - customerKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + customerKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5454,48 +7467,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} */ updateOAuth2Yahoo(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yahoo>; /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yahoo( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yahoo>; updateOAuth2Yahoo( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yahoo> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5505,15 +7538,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5539,48 +7572,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yandex configuration. * - * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} */ updateOAuth2Yandex(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yandex>; /** * Update the project OAuth2 Yandex configuration. * - * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yandex( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yandex>; updateOAuth2Yandex( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yandex> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5590,15 +7643,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5624,58 +7677,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoho configuration. * - * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} */ updateOAuth2Zoho(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }): Promise<Models.OAuth2Zoho>; /** * Update the project OAuth2 Zoho configuration. * - * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoho( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2ZohoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2ZohoPrompt[] | null, ): Promise<Models.OAuth2Zoho>; updateOAuth2Zoho( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2ZohoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Zoho> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; if ( @@ -5685,24 +7758,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2ZohoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5711,12 +7784,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5725,48 +7798,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoom configuration. * - * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} */ updateOAuth2Zoom(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Zoom>; /** * Update the project OAuth2 Zoom configuration. * - * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoom( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Zoom>; updateOAuth2Zoom( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Zoom> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5776,15 +7870,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5810,7 +7904,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +8191,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + platforms: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +8213,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6098,6 +8221,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise<Models.PlatformAndroid>; /** * 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. @@ -6105,6 +8229,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +8238,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise<Models.PlatformAndroid>; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +8267,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +8306,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +8317,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6191,13 +8351,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }): Promise<Models.PlatformAndroid>; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +8368,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[] | null, ): Promise<Models.PlatformAndroid>; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + }; if ( paramsOrFirst && @@ -6224,18 +8397,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[] | null, }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +8436,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +8447,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +8561,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +8674,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +8782,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +8890,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8998,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +9106,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +9223,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +9340,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +9557,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + policies: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +9628,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +9760,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +9892,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +10024,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +10223,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +10398,209 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise<Models.Project>; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise<Models.Project>; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise<Models.Project> { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +10658,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7757,38 +10740,38 @@ export class Project { * * 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. + * @param {number | null} 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<Models.Project>} */ updatePasswordHistoryPolicy(params: { - total?: number; + total?: number | null; }): Promise<Models.Project>; /** * 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. + * @param {number | null} 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<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy(total?: number | null): Promise<Models.Project>; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -7809,7 +10792,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +10924,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +11079,224 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise<Models.Project>; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise<Models.Project>; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise<Models.Project> { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +11409,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +11484,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +11616,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +11748,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,40 +11878,116 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ - updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + updateUserLimitPolicy(params: { + total?: number | null; + }): Promise<Models.Project>; /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy(total?: number | null): Promise<Models.Project>; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -8345,15 +12008,89 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +12100,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +12112,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +12130,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +12142,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +12152,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +12164,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +12280,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,104 +12435,179 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * - * @param {string} params.host - SMTP server hostname (domain) - * @param {number} params.port - SMTP server port - * @param {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} params.host - SMTP server hostname (domain) + * @param {number | null} params.port - SMTP server port + * @param {string | null} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ updateSMTP(params?: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }): Promise<Models.Project>; /** * 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. * - * @param {string} host - SMTP server hostname (domain) - * @param {number} port - SMTP server port - * @param {string} username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} host - SMTP server hostname (domain) + * @param {number | null} port - SMTP server port + * @param {string | null} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @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, + host?: string | null, + port?: number | null, + username?: string | null, + password?: string | null, + senderEmail?: string | null, + senderName?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, + secure?: ProjectSMTPSecure | null, + enabled?: boolean | null, ): Promise<Models.Project>; updateSMTP( paramsOrFirst?: | { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - number?, - string?, - string?, - string?, - string?, - string?, - string?, - ProjectSMTPSecure?, - boolean?, + (number | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectSMTPSecure | null)?, + (boolean | null)?, ] ): Promise<Models.Project> { let params: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; if ( @@ -8725,29 +12617,29 @@ export class Project { !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; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; } else { params = { - host: paramsOrFirst as string, - port: rest[0] as number, - username: rest[1] as string, - password: rest[2] as string, - senderEmail: rest[3] as string, - senderName: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, - secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean, + host: paramsOrFirst as string | null, + port: rest[0] as number | null, + username: rest[1] as string | null, + password: rest[2] as string | null, + senderEmail: rest[3] as string | null, + senderName: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, + secure: rest[7] as ProjectSMTPSecure | null, + enabled: rest[8] as boolean | null, }; } @@ -8801,7 +12693,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +12889,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + templates: [], + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8931,36 +12927,36 @@ export class Project { * * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. - * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} params.senderName - Name of the email sender. - * @param {string} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Reply to name. + * @param {string | null} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} params.senderName - Name of the email sender. + * @param {string | null} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} */ updateEmailTemplate(params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.EmailTemplate>; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} subject - Subject of the email template. Can be up to 255 characters. - * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} senderName - Name of the email sender. - * @param {string} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Reply to name. + * @param {string | null} subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} senderName - Name of the email sender. + * @param {string | null} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8968,45 +12964,45 @@ export class Project { updateEmailTemplate( templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, - subject?: string, - message?: string, - senderName?: string, - senderEmail?: string, - replyToEmail?: string, - replyToName?: string, + subject?: string | null, + message?: string | null, + senderName?: string | null, + senderEmail?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.EmailTemplate>; updateEmailTemplate( paramsOrFirst: | { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; } | ProjectEmailTemplateId, ...rest: [ ProjectEmailTemplateLocale?, - string?, - string?, - string?, - string?, - string?, - string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.EmailTemplate> { let params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -9025,23 +13021,23 @@ export class Project { params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, locale: rest[0] as ProjectEmailTemplateLocale, - subject: rest[1] as string, - message: rest[2] as string, - senderName: rest[3] as string, - senderEmail: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, + subject: rest[1] as string | null, + message: rest[2] as string | null, + senderName: rest[3] as string | null, + senderEmail: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, }; } @@ -9092,7 +13088,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +13188,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +13275,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +13416,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,58 +13490,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ updateVariable( variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.Variable> { let params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -9468,16 +13570,16 @@ export class Project { ) { params = (paramsOrFirst || {}) as { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } else { params = { variableId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean, + key: rest[0] as string | null, + value: rest[1] as string | null, + secret: rest[2] as boolean | null, }; } @@ -9512,7 +13614,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..162a7bf 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,13 +111,28 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -124,7 +144,7 @@ export class Proxy { /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -174,7 +194,43 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + rules: [], + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +288,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +404,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +566,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +680,144 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} params.domain - Domain that receives email. + * @param {string} params.functionId - ID of function to execute. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createSMTPRule(params: { + domain: string; + functionId: string; + branch?: string; + }): Promise<Models.ProxyRule>; + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} domain - Domain that receives email. + * @param {string} functionId - ID of function to execute. + * @param {string} branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSMTPRule( + domain: string, + functionId: string, + branch?: string, + ): Promise<Models.ProxyRule>; + createSMTPRule( + paramsOrFirst: + { domain: string; functionId: string; branch?: string } | string, + ...rest: [string?, string?] + ): Promise<Models.ProxyRule> { + 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, + }; + } + + 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"', + ); + } + const apiPath = '/proxy/rules/smtp'; + const apiPayload: Payload = {}; + if (typeof domain !== 'undefined') { + apiPayload['domain'] = domain; + } + if (typeof functionId !== 'undefined') { + apiPayload['functionId'] = functionId; + } + if (typeof branch !== 'undefined') { + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +870,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +1001,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2424cc0 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,79 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + sites: [], + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +550,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +662,47 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + frameworks: [], + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + runtimes: [], + adapters: [], + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +770,33 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +847,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -667,16 +928,16 @@ export class Sites { * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} */ @@ -695,16 +956,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }): Promise<Models.Site>; /** * Update site by its unique ID. @@ -723,16 +984,16 @@ export class Sites { * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} * @deprecated Use the object parameter style method for a better developer experience. @@ -752,16 +1013,16 @@ export class Sites { adapter?: Adapter, fallbackFile?: string, installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, runtimeSpecification?: string, deploymentRetention?: number, - scopes?: ProjectKeyScopes[], + scopes?: ProjectKeyScopes[] | null, ): Promise<Models.Site>; update( paramsOrFirst: @@ -780,16 +1041,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; } | string, ...rest: [ @@ -806,16 +1067,16 @@ export class Sites { Adapter?, string?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, string?, number?, - ProjectKeyScopes[]?, + (ProjectKeyScopes[] | null)?, ] ): Promise<Models.Site> { let params: { @@ -833,16 +1094,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; if ( @@ -865,16 +1126,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; } else { params = { @@ -892,16 +1153,16 @@ export class Sites { adapter: rest[10] as Adapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, - providerRepositoryId: rest[13] as string, + providerRepositoryId: rest[13] as string | null, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - providerBranches: rest[17] as string[], - providerPaths: rest[18] as string[], - buildSpecification: rest[19] as string, + providerBranches: rest[17] as string[] | null, + providerPaths: rest[18] as string[] | null, + buildSpecification: rest[19] as string | null, runtimeSpecification: rest[20] as string, deploymentRetention: rest[21] as number, - scopes: rest[22] as ProjectKeyScopes[], + scopes: rest[22] as ProjectKeyScopes[] | null, }; } @@ -1022,7 +1283,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1472,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1635,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1910,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2118,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2270,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2381,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2677,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2795,59 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2910,48 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3093,37 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3249,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3336,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2586,27 +3363,27 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2614,28 +3391,33 @@ export class Sites { updateVariable( siteId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2646,17 +3428,17 @@ export class Sites { params = (paramsOrFirst || {}) as { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2694,7 +3476,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..d810652 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,43 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + buckets: [], + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -101,7 +138,7 @@ export class Storage { * * @param {string} params.bucketId - 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 - Bucket name - * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -116,7 +153,7 @@ export class Storage { createBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -131,7 +168,7 @@ export class Storage { * * @param {string} bucketId - 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 - Bucket name - * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -147,7 +184,7 @@ export class Storage { createBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, @@ -162,7 +199,7 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -175,7 +212,7 @@ export class Storage { | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, number?, @@ -189,7 +226,7 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -208,7 +245,7 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -222,7 +259,7 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, maximumFileSize: rest[4] as number, @@ -296,7 +333,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +413,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,13 +446,13 @@ export class Storage { * * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.name - Bucket name - * @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 {string[] | null} 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.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -374,13 +461,13 @@ export class Storage { updateBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }): Promise<Models.Bucket>; @@ -389,13 +476,13 @@ export class Storage { * * @param {string} bucketId - Bucket unique ID. * @param {string} name - Bucket name - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -405,13 +492,13 @@ export class Storage { updateBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, - maximumFileSize?: number, + maximumFileSize?: number | null, allowedFileExtensions?: string[], - compression?: Compression, - encryption?: boolean, + compression?: Compression | null, + encryption?: boolean | null, antivirus?: boolean, transformations?: boolean, ): Promise<Models.Bucket>; @@ -420,26 +507,26 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; } | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, - number?, + (number | null)?, string[]?, - Compression?, - boolean?, + (Compression | null)?, + (boolean | null)?, boolean?, boolean?, ] @@ -447,13 +534,13 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -466,13 +553,13 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -480,13 +567,13 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, - maximumFileSize: rest[4] as number, + maximumFileSize: rest[4] as number | null, allowedFileExtensions: rest[5] as string[], - compression: rest[6] as Compression, - encryption: rest[7] as boolean, + compression: rest[6] as Compression | null, + encryption: rest[7] as boolean | null, antivirus: rest[8] as boolean, transformations: rest[9] as boolean, }; @@ -554,7 +641,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +824,45 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + files: [], + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1084,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -943,7 +1120,7 @@ export class Storage { * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.fileId - File ID. * @param {string} params.name - File name. - * @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 {string[] | null} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ @@ -951,7 +1128,7 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }): Promise<Models.File>; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -959,7 +1136,7 @@ export class Storage { * @param {string} bucketId - Bucket unique ID. * @param {string} fileId - File ID. * @param {string} name - File name. - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} * @deprecated Use the object parameter style method for a better developer experience. @@ -968,7 +1145,7 @@ export class Storage { bucketId: string, fileId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, ): Promise<Models.File>; updateFile( paramsOrFirst: @@ -976,16 +1153,16 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.File> { let params: { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; if ( @@ -997,14 +1174,14 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; } 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[] | null, }; } @@ -1038,7 +1215,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..adb947d 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,69 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,7 +167,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -110,7 +177,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -121,7 +188,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -132,7 +199,7 @@ export class TablesDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -142,10 +209,10 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -153,7 +220,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -167,7 +234,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -176,7 +243,7 @@ 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 | null, }; } @@ -222,7 +289,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +359,42 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +462,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +542,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +616,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +722,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +870,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +942,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,9 +1002,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -712,9 +1012,9 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -722,9 +1022,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -733,9 +1033,9 @@ export class TablesDB { databaseId: string, name?: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -743,20 +1043,26 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -768,18 +1074,18 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -822,7 +1128,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,33 +1240,33 @@ export class TablesDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -918,12 +1275,12 @@ export class TablesDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -950,7 +1307,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,11 +1420,50 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + migrations: [], + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} params.databaseId - Database ID. * @param {string} params.specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1025,7 +1477,7 @@ export class TablesDB { autoCutover?: boolean; }): Promise<Models.DatabaseMigration>; /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} databaseId - Database ID. * @param {string} specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1105,7 +1557,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1658,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1253,7 +1761,7 @@ export class TablesDB { } /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} params.databaseId - Database ID. * @param {string} params.migrationId - Migration ID. @@ -1265,7 +1773,7 @@ export class TablesDB { migrationId: string; }): Promise<Models.DatabaseMigration>; /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} databaseId - Database ID. * @param {string} migrationId - Migration ID. @@ -1327,7 +1835,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1967,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2054,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2138,52 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2287,59 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + tables: [], + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1656,11 +2348,11 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - 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 - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} params.columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} */ @@ -1668,7 +2360,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1680,11 +2372,11 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - 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 - Table 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 {string[] | null} 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} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1693,7 +2385,7 @@ export class TablesDB { databaseId: string, tableId: string, name: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, columns?: object[], @@ -1705,7 +2397,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1715,7 +2407,7 @@ export class TablesDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1726,7 +2418,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1742,7 +2434,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1753,7 +2445,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], @@ -1816,7 +2508,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2619,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1895,7 +2669,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.name - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1906,7 +2680,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1917,7 +2691,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} name - Table 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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1929,7 +2703,7 @@ export class TablesDB { databaseId: string, tableId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1940,19 +2714,26 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Table> { let params: { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1967,7 +2748,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1977,7 +2758,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -2028,7 +2809,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +3023,20 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + columns: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2212,9 +3047,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2224,9 +3059,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnBigint>; /** @@ -2237,9 +3072,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2250,9 +3085,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnBigint>; createBigIntColumn( @@ -2262,9 +3097,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -2272,9 +3107,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnBigint> { @@ -2283,9 +3118,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -2299,9 +3134,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -2310,9 +3145,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -2373,7 +3208,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,10 +3236,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} */ @@ -2396,10 +3248,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnBigint>; /** * Update a bigint column. Changing the `default` value will not update already existing rows. @@ -2409,10 +3261,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2422,10 +3274,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnBigint>; updateBigIntColumn( paramsOrFirst: @@ -2434,20 +3286,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnBigint> { let params: { @@ -2455,10 +3307,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -2471,10 +3323,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -2482,10 +3334,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -2549,7 +3401,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2560,7 +3429,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2570,7 +3439,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.ColumnBoolean>; /** @@ -2581,7 +3450,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2592,7 +3461,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.ColumnBoolean>; createBooleanColumn( @@ -2602,18 +3471,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -2627,7 +3496,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -2636,7 +3505,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -2690,7 +3559,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2700,8 +3586,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} */ @@ -2710,8 +3596,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.ColumnBoolean>; /** * Update a boolean column. Changing the `default` value will not update already existing rows. @@ -2720,8 +3606,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2731,8 +3617,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.ColumnBoolean>; updateBooleanColumn( paramsOrFirst: @@ -2741,19 +3627,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2766,8 +3658,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2775,8 +3667,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2832,7 +3724,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2842,7 +3751,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2852,7 +3761,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnDatetime>; /** @@ -2862,7 +3771,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2873,7 +3782,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnDatetime>; createDatetimeColumn( @@ -2883,18 +3792,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2908,7 +3817,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2917,7 +3826,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2971,7 +3880,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2981,8 +3907,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} */ @@ -2991,8 +3917,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnDatetime>; /** * Update a date time column. Changing the `default` value will not update already existing rows. @@ -3001,8 +3927,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3012,8 +3938,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnDatetime>; updateDatetimeColumn( paramsOrFirst: @@ -3022,19 +3948,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3047,8 +3979,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3056,8 +3988,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3113,7 +4045,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3124,7 +4073,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3134,7 +4083,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEmail>; /** @@ -3145,7 +4094,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3156,7 +4105,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEmail>; createEmailColumn( @@ -3166,18 +4115,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3191,7 +4140,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3200,7 +4149,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3253,7 +4202,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,8 +4231,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} */ @@ -3274,8 +4241,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEmail>; /** * Update an email column. Changing the `default` value will not update already existing rows. @@ -3285,8 +4252,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3296,8 +4263,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEmail>; updateEmailColumn( paramsOrFirst: @@ -3306,19 +4273,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3331,8 +4304,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3340,8 +4313,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3397,7 +4370,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3408,7 +4399,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3419,7 +4410,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEnum>; /** @@ -3430,7 +4421,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3442,7 +4433,7 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEnum>; createEnumColumn( @@ -3453,11 +4444,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3465,7 +4463,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3480,7 +4478,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3490,7 +4488,7 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -3552,7 +4550,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3564,8 +4581,8 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} */ @@ -3575,8 +4592,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEnum>; /** * Update an enum column. Changing the `default` value will not update already existing rows. @@ -3587,8 +4604,8 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3599,8 +4616,8 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEnum>; updateEnumColumn( paramsOrFirst: @@ -3610,11 +4627,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3622,8 +4646,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3637,8 +4661,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3647,8 +4671,8 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3713,7 +4737,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3724,9 +4767,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3736,9 +4779,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.ColumnFloat>; /** @@ -3749,9 +4792,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3762,9 +4805,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.ColumnFloat>; createFloatColumn( @@ -3774,9 +4817,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3784,9 +4827,9 @@ export class TablesDB { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.ColumnFloat> { @@ -3795,9 +4838,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3811,9 +4854,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3822,9 +4865,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3885,7 +4928,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3896,10 +4956,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} */ @@ -3908,10 +4968,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.ColumnFloat>; /** * Update a float column. Changing the `default` value will not update already existing rows. @@ -3921,10 +4981,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3934,10 +4994,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.ColumnFloat>; updateFloatColumn( paramsOrFirst: @@ -3946,20 +5006,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.ColumnFloat> { let params: { @@ -3967,10 +5027,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3983,10 +5043,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3994,10 +5054,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -4061,7 +5121,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4072,9 +5149,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4084,9 +5161,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnInteger>; /** @@ -4097,9 +5174,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4110,9 +5187,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnInteger>; createIntegerColumn( @@ -4122,9 +5199,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -4132,9 +5209,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnInteger> { @@ -4143,9 +5220,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -4159,9 +5236,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -4170,9 +5247,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -4234,7 +5311,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4245,10 +5339,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} */ @@ -4257,10 +5351,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnInteger>; /** * Update an integer column. Changing the `default` value will not update already existing rows. @@ -4270,10 +5364,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4283,10 +5377,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnInteger>; updateIntegerColumn( paramsOrFirst: @@ -4295,20 +5389,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnInteger> { let params: { @@ -4316,10 +5410,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -4332,10 +5426,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -4343,10 +5437,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -4410,7 +5504,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4421,7 +5532,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4431,7 +5542,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnIp>; /** @@ -4442,7 +5553,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4453,7 +5564,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnIp>; createIpColumn( @@ -4463,18 +5574,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -4488,7 +5599,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -4497,7 +5608,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -4550,7 +5661,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4561,8 +5690,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} */ @@ -4571,8 +5700,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnIp>; /** * Update an ip column. Changing the `default` value will not update already existing rows. @@ -4582,8 +5711,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4593,8 +5722,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnIp>; updateIpColumn( paramsOrFirst: @@ -4603,19 +5732,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4628,8 +5763,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4637,8 +5772,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4694,7 +5829,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4704,7 +5857,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4713,7 +5866,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnLine>; /** * Create a geometric line column. @@ -4722,7 +5875,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4732,7 +5885,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnLine>; createLineColumn( paramsOrFirst: @@ -4741,17 +5894,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4764,7 +5917,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4772,7 +5925,7 @@ export class TablesDB { 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[][] | null, }; } @@ -4820,7 +5973,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4830,8 +6000,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4840,8 +6010,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnLine>; /** * Update a line column. Changing the `default` value will not update already existing rows. @@ -4850,8 +6020,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4861,8 +6031,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnLine>; updateLineColumn( paramsOrFirst: @@ -4871,19 +6041,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4896,8 +6072,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4905,8 +6081,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4957,7 +6133,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4968,7 +6161,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -4979,7 +6172,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnLongtext>; @@ -4991,7 +6184,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5003,7 +6196,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnLongtext>; @@ -5014,19 +6207,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5041,7 +6241,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5051,7 +6251,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5110,7 +6310,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5121,8 +6338,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} */ @@ -5131,8 +6348,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnLongtext>; /** * Update a longtext column. Changing the `default` value will not update already existing rows. @@ -5142,8 +6359,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5153,8 +6370,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnLongtext>; updateLongtextColumn( paramsOrFirst: @@ -5163,19 +6380,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5188,8 +6411,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5197,8 +6420,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5254,7 +6477,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5265,7 +6505,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5276,7 +6516,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnMediumtext>; @@ -5288,7 +6528,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5300,7 +6540,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnMediumtext>; @@ -5311,19 +6551,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5338,7 +6585,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5348,7 +6595,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5407,7 +6654,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5418,8 +6682,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} */ @@ -5428,8 +6692,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnMediumtext>; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -5439,8 +6703,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5450,8 +6714,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnMediumtext>; updateMediumtextColumn( paramsOrFirst: @@ -5460,19 +6724,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5485,8 +6755,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5494,8 +6764,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5551,7 +6821,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5561,7 +6848,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5570,7 +6857,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.ColumnPoint>; /** * Create a geometric point column. @@ -5579,7 +6866,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5589,7 +6876,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.ColumnPoint>; createPointColumn( paramsOrFirst: @@ -5598,17 +6885,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -5621,7 +6908,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -5629,7 +6916,7 @@ export class TablesDB { 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[] | null, }; } @@ -5677,7 +6964,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5687,8 +6991,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5697,8 +7001,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.ColumnPoint>; /** * Update a point column. Changing the `default` value will not update already existing rows. @@ -5707,8 +7011,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5718,8 +7022,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.ColumnPoint>; updatePointColumn( paramsOrFirst: @@ -5728,19 +7032,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5753,8 +7063,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5762,8 +7072,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5814,7 +7124,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5824,7 +7151,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5833,7 +7160,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnPolygon>; /** * Create a geometric polygon column. @@ -5842,7 +7169,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5852,7 +7179,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnPolygon>; createPolygonColumn( paramsOrFirst: @@ -5861,17 +7188,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5884,7 +7211,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5892,7 +7219,7 @@ export class TablesDB { 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[][] | null, }; } @@ -5941,7 +7268,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5951,8 +7295,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5961,8 +7305,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnPolygon>; /** * Update a polygon column. Changing the `default` value will not update already existing rows. @@ -5971,8 +7315,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5982,8 +7326,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnPolygon>; updatePolygonColumn( paramsOrFirst: @@ -5992,19 +7336,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -6017,8 +7367,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -6026,8 +7376,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -6078,7 +7428,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6090,8 +7457,8 @@ export class TablesDB { * @param {string} params.relatedTableId - Related Table ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Column Key. - * @param {string} params.twoWayKey - Two Way Column Key. + * @param {string | null} params.key - Column Key. + * @param {string | null} params.twoWayKey - Two Way Column Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6102,8 +7469,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.ColumnRelationship>; /** @@ -6115,8 +7482,8 @@ export class TablesDB { * @param {string} relatedTableId - Related Table ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Column Key. - * @param {string} twoWayKey - Two Way Column Key. + * @param {string | null} key - Column Key. + * @param {string | null} twoWayKey - Two Way Column Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6128,8 +7495,8 @@ export class TablesDB { relatedTableId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.ColumnRelationship>; createRelationshipColumn( @@ -6140,8 +7507,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -6150,8 +7517,8 @@ export class TablesDB { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.ColumnRelationship> { @@ -6161,8 +7528,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -6177,8 +7544,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -6188,8 +7555,8 @@ export class TablesDB { relatedTableId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -6251,7 +7618,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6261,8 +7650,8 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. + * @param {RelationMutate | null} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} */ @@ -6270,8 +7659,8 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }): Promise<Models.ColumnRelationship>; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -6280,8 +7669,8 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. + * @param {RelationMutate | null} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6290,8 +7679,8 @@ export class TablesDB { databaseId: string, tableId: string, key: string, - onDelete?: RelationMutate, - newKey?: string, + onDelete?: RelationMutate | null, + newKey?: string | null, ): Promise<Models.ColumnRelationship>; updateRelationshipColumn( paramsOrFirst: @@ -6299,18 +7688,18 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, (RelationMutate | null)?, (string | null)?] ): Promise<Models.ColumnRelationship> { let params: { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; if ( @@ -6322,16 +7711,16 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; } 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, + onDelete: rest[2] as RelationMutate | null, + newKey: rest[3] as string | null, }; } @@ -6373,7 +7762,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6385,7 +7796,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6398,7 +7809,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnString>; @@ -6411,7 +7822,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6424,7 +7835,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnString>; @@ -6436,7 +7847,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6446,7 +7857,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6457,7 +7868,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6473,7 +7884,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6484,7 +7895,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6549,7 +7960,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6560,9 +7989,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the string column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the string column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6572,9 +8001,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnString>; /** * Update a string column. Changing the `default` value will not update already existing rows. @@ -6584,9 +8013,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the string column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the string column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6596,9 +8025,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnString>; updateStringColumn( paramsOrFirst: @@ -6607,21 +8036,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnString> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6634,9 +8070,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6644,9 +8080,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6706,7 +8142,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6717,7 +8171,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6728,7 +8182,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnText>; @@ -6740,7 +8194,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6752,7 +8206,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnText>; @@ -6763,19 +8217,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6790,7 +8251,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6800,7 +8261,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6858,7 +8319,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6869,8 +8347,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} */ @@ -6879,8 +8357,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnText>; /** * Update a text column. Changing the `default` value will not update already existing rows. @@ -6890,8 +8368,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6901,8 +8379,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnText>; updateTextColumn( paramsOrFirst: @@ -6911,19 +8389,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6936,8 +8420,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6945,8 +8429,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7002,7 +8486,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7013,7 +8514,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7023,7 +8524,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnUrl>; /** @@ -7034,7 +8535,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7045,7 +8546,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnUrl>; createUrlColumn( @@ -7055,18 +8556,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -7080,7 +8581,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -7089,7 +8590,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -7142,7 +8643,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7153,8 +8672,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} */ @@ -7163,8 +8682,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnUrl>; /** * Update an url column. Changing the `default` value will not update already existing rows. @@ -7174,8 +8693,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7185,8 +8704,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnUrl>; updateUrlColumn( paramsOrFirst: @@ -7195,19 +8714,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -7220,8 +8745,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -7229,8 +8754,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7286,7 +8811,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7298,7 +8841,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7310,7 +8853,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnVarchar>; @@ -7323,7 +8866,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7336,7 +8879,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnVarchar>; @@ -7348,7 +8891,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -7358,7 +8901,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -7369,7 +8912,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7385,7 +8928,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7396,7 +8939,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -7462,7 +9005,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7473,9 +9034,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the varchar column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the varchar column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} */ @@ -7484,9 +9045,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnVarchar>; /** * Update a varchar column. Changing the `default` value will not update already existing rows. @@ -7496,9 +9057,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the varchar column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the varchar column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7508,9 +9069,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnVarchar>; updateVarcharColumn( paramsOrFirst: @@ -7519,21 +9080,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnVarchar> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -7546,9 +9114,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -7556,9 +9124,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7618,7 +9186,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,12 +9533,43 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -7975,7 +9592,7 @@ export class TablesDB { }): Promise<Models.ColumnIndex>; /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -8109,7 +9726,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9831,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +10062,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8415,8 +10101,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -8427,8 +10113,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -8437,8 +10123,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8450,8 +10136,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8462,8 +10148,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8472,8 +10158,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -8483,8 +10169,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8499,8 +10185,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8510,8 +10196,8 @@ export class TablesDB { data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8561,7 +10247,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8570,7 +10274,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} params.rows - Array of rows data as JSON objects. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8578,7 +10282,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8586,7 +10290,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} rows - Array of rows data as JSON objects. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8595,7 +10299,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; createRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8603,16 +10307,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8624,14 +10328,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8670,7 +10374,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8680,7 +10413,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8688,7 +10421,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8697,7 +10430,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8706,7 +10439,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; upsertRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8714,16 +10447,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8735,14 +10468,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8781,7 +10514,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8791,7 +10553,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column 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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8800,7 +10562,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8809,7 +10571,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column 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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8819,7 +10581,7 @@ export class TablesDB { tableId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; updateRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8828,17 +10590,17 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8851,7 +10613,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -8859,7 +10621,7 @@ export class TablesDB { 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 | null, }; } @@ -8899,7 +10661,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10796,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10943,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9133,8 +10971,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9145,8 +10983,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -9155,8 +10993,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9168,8 +11006,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; upsertRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9181,8 +11019,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9191,8 +11029,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9202,8 +11040,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9219,8 +11057,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9231,8 +11069,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9277,7 +11115,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9287,8 +11143,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9299,8 +11155,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -9309,8 +11165,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9322,8 +11178,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; updateRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9335,8 +11191,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9345,8 +11201,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9356,8 +11212,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9373,8 +11229,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9385,8 +11241,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9431,7 +11287,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9549,8 +11423,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9560,8 +11434,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Decrement a specific column of a row by a given value. @@ -9571,8 +11445,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9583,8 +11457,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Row>; decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9594,11 +11468,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9606,8 +11487,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -9621,8 +11502,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9631,8 +11512,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9683,7 +11564,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9694,8 +11593,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9705,8 +11604,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Increment a specific column of a row by a given value. @@ -9716,8 +11615,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9728,8 +11627,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Row>; incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9739,11 +11638,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9751,8 +11657,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -9766,8 +11672,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9776,8 +11682,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9828,6 +11734,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..8e9f2ae 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,34 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + teams: [], + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +205,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +278,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +368,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +517,38 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +638,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +732,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,21 +760,21 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} teamId - Team ID. * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. @@ -631,22 +782,22 @@ export class Teams { updateInstallation( teamId: string, installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: | { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.AppInstallation> { let params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; if ( @@ -657,13 +808,13 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string, + authorizationDetails: rest[1] as string | null, }; } @@ -696,7 +847,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1041,44 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -890,6 +1098,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} */ @@ -901,6 +1110,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise<Models.Membership>; /** * 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. @@ -919,6 +1129,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} * @deprecated Use the object parameter style method for a better developer experience. @@ -931,6 +1142,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise<Models.Membership>; createMembership( paramsOrFirst: @@ -942,9 +1154,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise<Models.Membership> { let params: { teamId: string; @@ -954,6 +1175,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -969,6 +1191,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -979,6 +1202,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -989,6 +1213,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1018,6 +1243,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1026,7 +1254,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1354,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1471,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1688,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..580a3d4 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,36 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -116,21 +150,21 @@ export class Tokens { * * @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 unique ID. - * @param {string} params.expire - Token expiry date + * @param {string | null} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ createFileToken(params: { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * * @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 unique ID. - * @param {string} expire - Token expiry date + * @param {string | null} expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. @@ -138,14 +172,19 @@ export class Tokens { createFileToken( bucketId: string, fileId: string, - expire?: string, + expire?: string | null, ): Promise<Models.ResourceToken>; createFileToken( paramsOrFirst: - { bucketId: string; fileId: string; expire?: string } | string, - ...rest: [string?, string?] + | { bucketId: string; fileId: string; expire?: string | null } + | string, + ...rest: [string?, (string | null)?] ): Promise<Models.ResourceToken> { - let params: { bucketId: string; fileId: string; expire?: string }; + let params: { + bucketId: string; + fileId: string; + expire?: string | null; + }; if ( paramsOrFirst && @@ -155,13 +194,13 @@ export class Tokens { params = (paramsOrFirst || {}) as { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string, + expire: rest[1] as string | null, }; } @@ -191,7 +230,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,36 +303,57 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} params.tokenId - Token unique ID. - * @param {string} params.expire - File token expiry date + * @param {string | null} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ update(params: { tokenId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} tokenId - Token unique ID. - * @param {string} expire - File token expiry date + * @param {string | null} expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; update( - paramsOrFirst: { tokenId: string; expire?: string } | string, - ...rest: [string?] + tokenId: string, + expire?: string | null, + ): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string; expire?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.ResourceToken> { - let params: { tokenId: string; expire?: string }; + let params: { tokenId: string; expire?: string | null }; if ( paramsOrFirst && @@ -284,12 +362,12 @@ export class Tokens { ) { params = (paramsOrFirst || {}) as { tokenId: string; - expire?: string; + expire?: string | null; }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string, + expire: rest[0] as string | null, }; } @@ -316,7 +394,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..77a515b 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,16 +94,70 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + users: [], + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new user. * * @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. - * @param {string} params.email - User email. - * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string | null} params.email - User email. + * @param {string | null} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} params.password - Plain text user password. Must be at least 8 chars. * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -107,18 +166,18 @@ export class Users { Preferences extends Models.Preferences = Models.DefaultPreferences, >(params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }): Promise<Models.User<Preferences>>; /** * Create a new user. * * @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. - * @param {string} email - User email. - * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string | null} email - User email. + * @param {string | null} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} password - Plain text user password. Must be at least 8 chars. * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -126,28 +185,28 @@ export class Users { */ create<Preferences extends Models.Preferences = Models.DefaultPreferences>( userId: string, - email?: string, - phone?: string, - password?: string, + email?: string | null, + phone?: string | null, + password?: string | null, name?: string, ): Promise<Models.User<Preferences>>; create<Preferences extends Models.Preferences = Models.DefaultPreferences>( paramsOrFirst: | { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [(string | null)?, (string | null)?, (string | null)?, string?] ): Promise<Models.User<Preferences>> { let params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; @@ -158,17 +217,17 @@ export class Users { ) { params = (paramsOrFirst || {}) as { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string, - phone: rest[1] as string, - password: rest[2] as string, + email: rest[0] as string | null, + phone: rest[1] as string | null, + password: rest[2] as string | null, name: rest[3] as string, }; } @@ -206,7 +265,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +420,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +575,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +697,40 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +898,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1053,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1307,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1518,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1690,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1790,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1959,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2083,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2301,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2446,44 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2558,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2675,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2930,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +3000,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3069,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3141,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3277,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3345,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3414,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3482,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3568,410 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise<Models.PasskeyList> { + 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, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise<Models.Passkey>; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4050,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4170,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4408,58 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4517,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4752,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4876,37 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5048,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5135,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5270,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5439,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5538,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5663,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..d2f0c5d 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,69 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class VectorsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class VectorsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class VectorsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,59 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1530,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1647,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1209,7 +1700,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} */ @@ -1220,7 +1711,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.VectorsdbCollection>; /** * Update a collection by its unique ID. @@ -1231,7 +1722,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1243,7 +1734,7 @@ export class VectorsDB { dimension?: number, permissions?: string[], documentSecurity?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.VectorsdbCollection>; updateCollection( paramsOrFirst: @@ -1254,10 +1745,17 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ...rest: [ + string?, + string?, + number?, + string[]?, + boolean?, + (boolean | null)?, + ] ): Promise<Models.VectorsdbCollection> { let params: { databaseId: string; @@ -1266,7 +1764,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -1281,7 +1779,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -1291,7 +1789,7 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean, + enabled: rest[5] as boolean | null, }; } @@ -1345,7 +1843,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2093,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2291,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2426,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2574,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2727,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2868,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +3035,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3193,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3380,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3567,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3810,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +4006,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4114,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3377,33 +4230,33 @@ export class VectorsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3412,12 +4265,12 @@ export class VectorsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3444,7 +4297,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4457,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4544,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4628,51 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..41404b9 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2415 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise<Models.WafRuleList>; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise<Models.WafRuleList>; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise<Models.WafRuleList> { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + rules: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleBypass>; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleBypass>; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleBypass>; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleBypass>; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise<Models.WafRuleChallenge>; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise<Models.WafRuleChallenge>; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.challengeType - Challenge type enforced by the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }): Promise<Models.WafRuleChallenge>; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} challengeType - Challenge type enforced by the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + challengeType?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + difficulty?: number | null, + ttl?: number | null, + ): Promise<Models.WafRuleChallenge>; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + challengeType: rest[4] as string | null, + priority: rest[5] as number | null, + enabled: rest[6] as boolean | null, + conditions: rest[7] as string[] | null, + difficulty: rest[8] as number | null, + ttl: rest[9] as number | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleDeny>; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleDeny>; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleDeny>; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleDeny>; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRateLimit>; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string | null, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number | null, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRateLimit>; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + (string | null)?, + string?, + string?, + string?, + (number | null)?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number | null, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRateLimit>; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} interval - Interval in seconds used for rate limiting. + * @param {string | null} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + limit?: number | null, + interval?: number | null, + key?: string | null, + maxBucketSize?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRateLimit>; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + limit: rest[4] as number | null, + interval: rest[5] as number | null, + key: rest[6] as string | null, + maxBucketSize: rest[7] as number | null, + priority: rest[8] as number | null, + enabled: rest[9] as boolean | null, + conditions: rest[10] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRedirect>; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRedirect>; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.location - Location used for redirect responses. + * @param {number | null} params.statusCode - Integer status code used for redirect responses. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRedirect>; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} location - Location used for redirect responses. + * @param {number | null} statusCode - Integer status code used for redirect responses. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + location?: string | null, + statusCode?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRedirect>; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + location: rest[4] as string | null, + statusCode: rest[5] as number | null, + priority: rest[6] as number | null, + enabled: rest[7] as boolean | null, + conditions: rest[8] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..32f492f 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,42 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + webhooks: [], + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,9 +122,9 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -97,7 +137,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -108,9 +148,9 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -124,7 +164,7 @@ export class Webhooks { tls?: boolean, authUsername?: string, authPassword?: string, - secret?: string, + secret?: string | null, ): Promise<Models.Webhook>; create( paramsOrFirst: @@ -137,7 +177,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; } | string, ...rest: [ @@ -148,7 +188,7 @@ export class Webhooks { boolean?, string?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -160,7 +200,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; if ( @@ -177,7 +217,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; } else { params = { @@ -189,7 +229,7 @@ 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 | null, }; } @@ -253,7 +293,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +372,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +408,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -333,7 +421,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }): Promise<Models.Webhook>; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -344,8 +432,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -358,7 +446,7 @@ export class Webhooks { enabled?: boolean, tls?: boolean, authUsername?: string, - authPassword?: string, + authPassword?: string | null, ): Promise<Models.Webhook>; update( paramsOrFirst: @@ -370,7 +458,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; } | string, ...rest: [ @@ -380,7 +468,7 @@ export class Webhooks { boolean?, boolean?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -391,7 +479,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; if ( @@ -407,7 +495,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; } else { params = { @@ -418,7 +506,7 @@ 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 | null, }; } @@ -478,7 +566,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -539,29 +651,32 @@ export class Webhooks { * 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. * * @param {string} params.webhookId - Webhook ID. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ updateSecret(params: { webhookId: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * 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. * * @param {string} webhookId - Webhook ID. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; updateSecret( - paramsOrFirst: { webhookId: string; secret?: string } | string, - ...rest: [string?] + webhookId: string, + secret?: string | null, + ): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string; secret?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.Webhook> { - let params: { webhookId: string; secret?: string }; + let params: { webhookId: string; secret?: string | null }; if ( paramsOrFirst && @@ -570,12 +685,12 @@ export class Webhooks { ) { params = (paramsOrFirst || {}) as { webhookId: string; - secret?: string; + secret?: string | null; }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string, + secret: rest[0] as string | null, }; } @@ -602,6 +717,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/topic.ts b/src/topic.ts index cd6cea0..071d5ae 100644 --- a/src/topic.ts +++ b/src/topic.ts @@ -1,6 +1,6 @@ /** * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding - * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). + * the level separator `/` or the MQTT wildcards `+` and `#`. */ function levelsOf(levels: unknown): string[] { if (!Array.isArray(levels)) { @@ -28,17 +28,14 @@ function levelsOf(levels: unknown): string[] { `"${level}" contains "/", split it: path([${parts}])`, ); } - if (level === '+') { - throw new Error('"+" is reserved, use any()'); - } if (level.includes('+')) { - throw new Error(`"${level}" contains "+", use any() for wildcards`); - } - if (level === '#') { - throw new Error('"#" is reserved, use all()'); + throw new Error(`"${level}" contains "+", not allowed in a topic`); } if (level.includes('#')) { - throw new Error(`"${level}" contains "#", use all() for wildcards`); + throw new Error(`"${level}" contains "#", not allowed in a topic`); + } + if (level.includes('\0')) { + throw new Error(`level at index ${index} contains a NUL character`); } return level; }); @@ -48,11 +45,7 @@ function levelsOf(levels: unknown): string[] { * Helper to build MQTT topics for `Push`, level by level. * * Topic.path(['user', userId, 'notification']); // "user/123/notification" - * Topic.path(['user']).any().path(['notification']); // "user/+/notification" - * Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#" - * - * `any()` matches exactly one level and `all()` everything below, at any depth (including the - * parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}. + * Topic.path(['org', orgId]).path(['logs']); // "org/42/logs" */ export class Topic { private constructor(private readonly levels: readonly string[]) {} @@ -62,41 +55,11 @@ export class Topic { return new Topic(levelsOf(levels)); } - /** Start a topic with a single-level wildcard (`+`). */ - static any(): Topic { - return new Topic(['+']); - } - - /** The multi-level wildcard alone (`#`): matches every topic. */ - static all(): ResolvedTopic { - return new ResolvedTopic(['#']); - } - /** Append the given levels. */ path(levels: string[]): Topic { return new Topic([...this.levels, ...levelsOf(levels)]); } - /** Append a single-level wildcard (`+`): matches exactly one level. */ - any(): Topic { - return new Topic([...this.levels, '+']); - } - - /** Append the multi-level wildcard (`#`) and end the topic. */ - all(): ResolvedTopic { - return new ResolvedTopic([...this.levels, '#']); - } - - toString(): string { - return this.levels.join('/'); - } -} - -/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */ -export class ResolvedTopic { - /** @internal Created by {@link Topic.all}. */ - constructor(private readonly levels: readonly string[]) {} - toString(): string { return this.levels.join('/'); } diff --git a/test/client.test.js b/test/client.test.js index 71bda01..82b9451 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -1,5 +1,6 @@ const { Client } = require('../dist/client'); const { InputFile } = require('../dist/inputFile'); +const { Query } = require('../dist/query'); const { fetch: mockedFetch, Response, Dispatcher } = require('undici'); jest.mock('undici', () => ({ @@ -45,6 +46,58 @@ describe('Client', () => { }); }); +describe('Client.prepareRequest', () => { + const url = () => new URL('https://cloud.appwrite.io/v1/rows'); + const params = () => ({ + data: [['a', 'b']], + queries: Query.builder().equal('status', 'active').limit(1), + filters: [Query.equal('status', 'active'), Query.builder().limit(1)], + }); + const queries = [Query.equal('status', 'active'), Query.limit(1)]; + + test('sends nested string arrays and flattened builders as JSON', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'application/json' }, + params(), + ); + + expect(JSON.parse(options.body)).toEqual({ + data: [['a', 'b']], + queries, + filters: queries, + }); + }); + + test('sends nested string arrays and flattened builders as query string', () => { + const { uri } = new Client().prepareRequest('GET', url(), {}, params()); + const search = new URL(uri).searchParams; + + expect(search.get('data[0][0]')).toBe('a'); + expect(search.get('data[0][1]')).toBe('b'); + expect(search.has('data[0]')).toBe(false); + expect([search.get('queries[0]'), search.get('queries[1]')]).toEqual( + queries, + ); + expect([search.get('filters[0]'), search.get('filters[1]')]).toEqual( + queries, + ); + }); + + test('sends flattened builders as multipart fields', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'multipart/form-data' }, + params(), + ); + + expect(options.body.getAll('queries[]')).toEqual(queries); + expect(options.body.getAll('filters[]')).toEqual(queries); + }); +}); + describe('Client.chunkedUpload', () => { const url = new URL( 'https://cloud.appwrite.io/v1/storage/buckets/bucket/files', diff --git a/test/query.test.js b/test/query.test.js index 52e9490..53c3bc8 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -1,35 +1,37 @@ -const { Query } = require('../dist/query'); +const { Query, normalizeQueries, flattenParam } = require('../dist/query'); + +const expectQuery = (query) => expect(JSON.parse(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'], }, ]; @@ -37,9 +39,11 @@ 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}}`, - ), + expectQuery(Query.equal('attr', t.value)).toEqual({ + method: 'equal', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -47,9 +51,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.notEqual('attr', t.value)).toEqual({ + method: 'notEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -57,9 +63,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThan('attr', t.value)).toEqual({ + method: 'lessThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -67,9 +75,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThanEqual('attr', t.value)).toEqual({ + method: 'lessThanEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -77,9 +87,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.greaterThan('attr', t.value)).toEqual({ + method: 'greaterThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -87,71 +99,396 @@ describe('Query', () => { 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}}`, - ), + expectQuery(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"]}`, - )); + expectQuery(Query.search('attr', 'keyword1 keyword2')).toEqual({ + method: 'search', + attribute: 'attr', + values: ['keyword1 keyword2'], + })); test('isNull', () => - expect(Query.isNull('attr')).toEqual( - `{"method":"isNull","attribute":"attr"}`, - )); + expectQuery(Query.isNull('attr')).toEqual({ + method: 'isNull', + attribute: 'attr', + })); test('isNotNull', () => - expect(Query.isNotNull('attr')).toEqual( - `{"method":"isNotNull","attribute":"attr"}`, - )); + expectQuery(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]}`, - )); + expectQuery(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]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(Query.select(['attr1', 'attr2'])).toEqual({ + method: 'select', + values: ['attr1', 'attr2'], + })); test('orderAsc', () => - expect(Query.orderAsc('attr')).toEqual( - `{"method":"orderAsc","attribute":"attr"}`, - )); + expectQuery(Query.orderAsc('attr')).toEqual({ + method: 'orderAsc', + attribute: 'attr', + })); test('orderDesc', () => - expect(Query.orderDesc('attr')).toEqual( - `{"method":"orderDesc","attribute":"attr"}`, - )); + expectQuery(Query.orderDesc('attr')).toEqual({ + method: 'orderDesc', + attribute: 'attr', + })); test('cursorBefore', () => - expect(Query.cursorBefore('attr')).toEqual( - '{"method":"cursorBefore","values":["attr"]}', - )); + expectQuery(Query.cursorBefore('attr')).toEqual({ + method: 'cursorBefore', + values: ['attr'], + })); test('cursorAfter', () => - expect(Query.cursorAfter('attr')).toEqual( - '{"method":"cursorAfter","values":["attr"]}', - )); + expectQuery(Query.cursorAfter('attr')).toEqual({ + method: 'cursorAfter', + values: ['attr'], + })); test('limit', () => - expect(Query.limit(1)).toEqual('{"method":"limit","values":[1]}')); + expectQuery(Query.limit(1)).toEqual({ method: 'limit', values: [1] })); test('offset', () => - expect(Query.offset(1)).toEqual('{"method":"offset","values":[1]}')); + expectQuery(Query.offset(1)).toEqual({ + method: 'offset', + values: [1], + })); + + test('count with alias', () => + expectQuery(Query.count('*', 'total')).toEqual({ + method: 'count', + attribute: '*', + values: ['total'], + })); + + test('count without alias', () => + expectQuery(Query.count()).toEqual({ + method: 'count', + attribute: '*', + })); + + test('countDistinct', () => + expectQuery(Query.countDistinct('year', 'uniqueYears')).toEqual({ + method: 'countDistinct', + attribute: 'year', + values: ['uniqueYears'], + })); + + test('sum', () => + expectQuery(Query.sum('price', 'total')).toEqual({ + method: 'sum', + attribute: 'price', + values: ['total'], + })); + + test('avg', () => + expectQuery(Query.avg('price', 'avgPrice')).toEqual({ + method: 'avg', + attribute: 'price', + values: ['avgPrice'], + })); + + test('min', () => + expectQuery(Query.min('price', 'lowest')).toEqual({ + method: 'min', + attribute: 'price', + values: ['lowest'], + })); + + test('max', () => + expectQuery(Query.max('price', 'highest')).toEqual({ + method: 'max', + attribute: 'price', + values: ['highest'], + })); + + test('stddev', () => + expectQuery(Query.stddev('price', 'sd')).toEqual({ + method: 'stddev', + attribute: 'price', + values: ['sd'], + })); + + test('stddevPop', () => + expectQuery(Query.stddevPop('price', 'sdp')).toEqual({ + method: 'stddevPop', + attribute: 'price', + values: ['sdp'], + })); + + test('stddevSamp', () => + expectQuery(Query.stddevSamp('price', 'sds')).toEqual({ + method: 'stddevSamp', + attribute: 'price', + values: ['sds'], + })); + + test('variance', () => + expectQuery(Query.variance('price', 'var')).toEqual({ + method: 'variance', + attribute: 'price', + values: ['var'], + })); + + test('varPop', () => + expectQuery(Query.varPop('price', 'vp')).toEqual({ + method: 'varPop', + attribute: 'price', + values: ['vp'], + })); + + test('varSamp', () => + expectQuery(Query.varSamp('price', 'vs')).toEqual({ + method: 'varSamp', + attribute: 'price', + values: ['vs'], + })); + + test('bitAnd', () => + expectQuery(Query.bitAnd('flags', 'band')).toEqual({ + method: 'bitAnd', + attribute: 'flags', + values: ['band'], + })); + + test('bitOr', () => + expectQuery(Query.bitOr('flags', 'bor')).toEqual({ + method: 'bitOr', + attribute: 'flags', + values: ['bor'], + })); + + test('bitXor', () => + expectQuery(Query.bitXor('flags', 'bxor')).toEqual({ + method: 'bitXor', + attribute: 'flags', + values: ['bxor'], + })); + + test('groupBy', () => + expectQuery(Query.groupBy(['status', 'year'])).toEqual({ + method: 'groupBy', + values: ['status', 'year'], + })); + + test('having nests parsed queries', () => { + const having = JSON.parse( + Query.having([Query.greaterThan('total', 1)]), + ); + expect(having.method).toEqual('having'); + expect(having.values[0].method).toEqual('greaterThan'); + expect(having.values[0].attribute).toEqual('total'); + expect(having.values[0].values).toEqual([1]); + }); + + test('distinct', () => + expectQuery(Query.distinct()).toEqual({ method: 'distinct' })); + + test('join', () => + expectQuery(Query.join('orders', '$id', 'customerId')).toEqual({ + method: 'join', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('leftJoin with alias', () => + expectQuery( + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + ).toEqual({ + method: 'leftJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId', 'ord'], + })); + + test('rightJoin', () => + expectQuery(Query.rightJoin('orders', '$id', 'customerId')).toEqual({ + method: 'rightJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('fullOuterJoin', () => + expectQuery(Query.fullOuterJoin('orders', '$id', 'customerId')).toEqual( + { + method: 'fullOuterJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + }, + )); + + test('on', () => + expectQuery(Query.on('$id', 'customerId')).toEqual({ + method: 'on', + values: ['$id', '=', 'customerId'], + })); + + test('nested leftJoin', () => { + const query = JSON.parse( + Query.leftJoin('orders', 'ord', [ + Query.on('$id', 'customerId'), + Query.equal('ord.status', 'paid'), + ]), + ); + expect(query.method).toEqual('leftJoin'); + expect(query.attribute).toEqual('orders'); + expect(query.values[0]).toEqual('ord'); + expect(query.values[1].method).toEqual('on'); + expect(query.values[2].method).toEqual('equal'); + }); + + test('crossJoin', () => + expectQuery(Query.crossJoin('orders', 'ord')).toEqual({ + method: 'crossJoin', + attribute: 'orders', + values: ['ord'], + })); + + test('vectorDot', () => + expectQuery(Query.vectorDot('embedding', [0.1, 0.2])).toEqual({ + method: 'vectorDot', + attribute: 'embedding', + values: [[0.1, 0.2]], + })); + + test('notCovers', () => + expectQuery(Query.notCovers('location', [1, 2])).toEqual({ + method: 'notCovers', + attribute: 'location', + values: [[1, 2]], + })); + + test('spatialEquals', () => + expectQuery(Query.spatialEquals('location', [1, 2])).toEqual({ + method: 'spatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('notSpatialEquals', () => + expectQuery(Query.notSpatialEquals('location', [1, 2])).toEqual({ + method: 'notSpatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('page', () => { + const queries = Query.page(2, 10).map((query) => JSON.parse(query)); + expect(queries).toEqual([ + { method: 'limit', values: [10] }, + { method: 'offset', values: [10] }, + ]); + }); + + test('builder build', () => { + const built = Query.builder() + .equal('status', 'published') + .leftJoin('orders', '$id', 'customerId', '=', 'ord') + .count('*', 'total') + .groupBy(['status']) + .limit(25) + .build(); + + expect(built).toEqual([ + Query.equal('status', 'published'), + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + Query.count('*', 'total'), + Query.groupBy(['status']), + Query.limit(25), + ]); + }); + + test('normalize builder wrapped in array', () => { + const builder = Query.builder().equal('status', 'active').limit(10); + expect(normalizeQueries([builder])).toEqual(builder.build()); + expect(normalizeQueries([builder.build()])).toEqual(builder.build()); + expect(normalizeQueries(builder)).toEqual(builder.build()); + }); + + test('normalize page wrapped in array', () => { + expect( + normalizeQueries([ + Query.equal('status', 'active'), + Query.page(2, 10), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(10), + Query.offset(10), + ]); + }); + + test('flattenParam spreads wrapped builder', () => { + expect(flattenParam([Query.builder().limit(1)])).toEqual([ + Query.limit(1), + ]); + }); + + test('flattenParam keeps nested numeric arrays', () => { + const geometry = [ + [1, 2], + [3, 4], + ]; + expect(flattenParam(geometry)).toEqual(geometry); + }); + + test('flattenParam keeps query string list', () => { + expect(flattenParam([Query.limit(1)])).toEqual([Query.limit(1)]); + }); + + test('flattenParam keeps nested string arrays', () => { + const value = [['a', 'b']]; + expect(flattenParam(value)).toEqual([['a', 'b']]); + }); + + test('flattenParam builds a builder value', () => { + expect( + flattenParam(Query.builder().equal('status', 'active').limit(1)), + ).toEqual([Query.equal('status', 'active'), Query.limit(1)]); + }); + + test('flattenParam splices builders among query strings', () => { + expect( + flattenParam([ + Query.equal('status', 'active'), + Query.builder().limit(1).offset(2), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(1), + Query.offset(2), + ]); + }); }); diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..0bd3f1c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -13,9 +13,9 @@ describe('Account', () => { 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', + $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, @@ -40,9 +40,9 @@ describe('Account', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Account', () => { }); 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', + $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', @@ -129,9 +129,9 @@ describe('Account', () => { }); 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', + $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', @@ -168,9 +168,9 @@ describe('Account', () => { }); 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', + $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, @@ -221,9 +221,9 @@ describe('Account', () => { }); 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', + $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, @@ -274,9 +274,9 @@ describe('Account', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Account', () => { }); 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', + $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, @@ -348,8 +348,8 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -363,8 +363,8 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -378,9 +378,9 @@ describe('Account', () => { }); 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', + $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', @@ -421,9 +421,9 @@ describe('Account', () => { }); 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', + $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', @@ -568,9 +568,9 @@ describe('Account', () => { }); 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', + $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, @@ -593,11 +593,101 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('<PASSKEY_ID>', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '<PASSKEY_ID>', + {}, + ); + + // 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', + $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, @@ -622,9 +712,9 @@ describe('Account', () => { }); 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', + $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, @@ -659,9 +749,9 @@ describe('Account', () => { }); 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', + $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, @@ -686,8 +776,8 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -706,8 +796,8 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -727,8 +817,8 @@ describe('Account', () => { }); test('test method createRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -744,8 +834,8 @@ describe('Account', () => { }); test('test method updateRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -788,9 +878,9 @@ describe('Account', () => { }); 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', + $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', @@ -828,9 +918,9 @@ describe('Account', () => { }); 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', + $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', @@ -871,9 +961,9 @@ describe('Account', () => { }); test('test method createIdTokenSession()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -914,9 +1004,9 @@ describe('Account', () => { }); 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', + $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', @@ -957,9 +1047,9 @@ describe('Account', () => { }); 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', + $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', @@ -1000,9 +1090,9 @@ describe('Account', () => { }); 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', + $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', @@ -1040,9 +1130,9 @@ describe('Account', () => { }); 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', + $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', @@ -1080,9 +1170,9 @@ describe('Account', () => { }); 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', + $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', @@ -1130,9 +1220,9 @@ describe('Account', () => { }); 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', + $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, @@ -1157,8 +1247,8 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1177,8 +1267,8 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1205,10 +1295,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('<CHALLENGE_ID>', {}); + + // 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', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1227,8 +1350,8 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1246,8 +1369,8 @@ describe('Account', () => { }); test('test method createVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1265,8 +1388,8 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1285,8 +1408,8 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1305,8 +1428,8 @@ describe('Account', () => { }); test('test method createEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1322,8 +1445,8 @@ describe('Account', () => { }); test('test method updateEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1342,8 +1465,8 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1359,8 +1482,8 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 5270074..4c59cab 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', actorType: 'user', actorId: '610fc2f985ee0', actorEmail: 'john@appwrite.io', diff --git a/test/services/advisor.test.js b/test/services/advisor.test.js index 777728a..b3ff64d 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -26,9 +26,9 @@ describe('Advisor', () => { }); 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', + $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/', @@ -71,9 +71,9 @@ describe('Advisor', () => { }); 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', + $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', diff --git a/test/services/apps.test.js b/test/services/apps.test.js index d79c42c..a63e37e 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -26,9 +26,9 @@ describe('Apps', () => { }); 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', + $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', @@ -89,9 +89,9 @@ describe('Apps', () => { }); 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', + $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', @@ -126,9 +126,9 @@ describe('Apps', () => { }); 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', + $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', @@ -186,9 +186,9 @@ describe('Apps', () => { }); 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', + $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: [], @@ -254,9 +254,9 @@ describe('Apps', () => { }); 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', + $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', @@ -273,9 +273,9 @@ describe('Apps', () => { }); 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', + $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', @@ -302,9 +302,9 @@ describe('Apps', () => { }); 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', + $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', @@ -352,9 +352,9 @@ describe('Apps', () => { }); 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', + $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', @@ -371,9 +371,9 @@ describe('Apps', () => { }); 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', + $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', @@ -400,9 +400,9 @@ describe('Apps', () => { }); 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', + $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', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index c65b1b9..ecd4504 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -84,9 +84,9 @@ describe('Avatars', () => { }); test('test method updatePhoto()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 922f68d..e1db580 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -26,9 +26,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -45,9 +45,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -87,10 +87,10 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -113,10 +113,10 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -134,10 +134,10 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -165,9 +165,9 @@ describe('Backups', () => { }); 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', + $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', @@ -199,9 +199,9 @@ describe('Backups', () => { }); 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', + $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', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2af87b0..502bcb0 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -26,10 +26,10 @@ describe('Databases', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -56,9 +56,9 @@ describe('Databases', () => { }); 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', + $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', @@ -73,9 +73,9 @@ describe('Databases', () => { }); 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', + $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', @@ -90,9 +90,9 @@ describe('Databases', () => { }); 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', + $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', @@ -117,9 +117,9 @@ describe('Databases', () => { }); 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', + $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', @@ -134,10 +134,10 @@ describe('Databases', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -151,10 +151,10 @@ describe('Databases', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,10 +191,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -218,10 +218,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -244,10 +244,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -304,8 +304,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -327,8 +327,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -351,8 +351,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -374,8 +374,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -398,8 +398,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -422,8 +422,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -447,8 +447,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -471,8 +471,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -496,8 +496,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -522,8 +522,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -549,8 +549,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -572,8 +572,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -596,8 +596,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -619,8 +619,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -643,8 +643,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -667,8 +667,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -692,8 +692,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -715,8 +715,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -738,8 +738,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -761,8 +761,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -785,8 +785,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -808,8 +808,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -832,8 +832,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -855,8 +855,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -878,8 +878,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -901,8 +901,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -924,8 +924,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -953,8 +953,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -981,8 +981,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1006,8 +1006,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1031,8 +1031,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1054,8 +1054,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1078,8 +1078,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1102,8 +1102,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1127,8 +1127,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1152,8 +1152,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1177,8 +1177,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1225,13 +1225,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1314,13 +1314,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1336,13 +1336,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1358,13 +1358,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1394,13 +1394,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1417,13 +1417,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1456,9 +1456,9 @@ describe('Databases', () => { }); 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', + $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', @@ -1482,9 +1482,9 @@ describe('Databases', () => { }); 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', + $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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..b56872d 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -26,10 +26,10 @@ describe('DocumentsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -132,9 +132,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -149,10 +149,10 @@ describe('DocumentsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -166,10 +166,10 @@ describe('DocumentsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -206,10 +206,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -259,10 +259,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -315,13 +315,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -404,13 +404,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -426,13 +426,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -448,13 +448,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -484,13 +484,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -507,13 +507,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -546,9 +546,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -572,9 +572,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -610,21 +610,17 @@ describe('DocumentsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/domains.test.js b/test/services/domains.test.js index fc86018..f77cb0e 100644 --- a/test/services/domains.test.js +++ b/test/services/domains.test.js @@ -26,9 +26,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -79,9 +79,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -112,9 +112,9 @@ describe('Domains', () => { }); test('test method updateNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -135,9 +135,9 @@ describe('Domains', () => { }); test('test method verifyNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -328,9 +328,9 @@ describe('Domains', () => { }); test('test method createRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -356,9 +356,9 @@ describe('Domains', () => { }); test('test method updateRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -385,9 +385,9 @@ describe('Domains', () => { }); test('test method createRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -413,9 +413,9 @@ describe('Domains', () => { }); test('test method updateRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -442,9 +442,9 @@ describe('Domains', () => { }); test('test method createRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -470,9 +470,9 @@ describe('Domains', () => { }); test('test method updateRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -499,9 +499,9 @@ describe('Domains', () => { }); test('test method createRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -527,9 +527,9 @@ describe('Domains', () => { }); test('test method updateRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -556,9 +556,9 @@ describe('Domains', () => { }); test('test method createRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -584,9 +584,9 @@ describe('Domains', () => { }); test('test method updateRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -613,9 +613,9 @@ describe('Domains', () => { }); test('test method createRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -641,9 +641,9 @@ describe('Domains', () => { }); test('test method updateRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -670,9 +670,9 @@ describe('Domains', () => { }); test('test method createRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -699,9 +699,9 @@ describe('Domains', () => { }); test('test method updateRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -729,9 +729,9 @@ describe('Domains', () => { }); test('test method createRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -757,9 +757,9 @@ describe('Domains', () => { }); test('test method updateRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -786,9 +786,9 @@ describe('Domains', () => { }); test('test method createRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -817,9 +817,9 @@ describe('Domains', () => { }); test('test method updateRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -849,9 +849,9 @@ describe('Domains', () => { }); test('test method createRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -876,9 +876,9 @@ describe('Domains', () => { }); test('test method updateRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -905,9 +905,9 @@ describe('Domains', () => { }); test('test method getRecord()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -941,9 +941,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -988,9 +988,9 @@ describe('Domains', () => { }); test('test method updateZone()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', diff --git a/test/services/functions.test.js b/test/services/functions.test.js index fba574b..b40183d 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -27,9 +27,9 @@ describe('Functions', () => { }); 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', + $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, @@ -100,9 +100,9 @@ describe('Functions', () => { }); 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', + $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, @@ -143,9 +143,9 @@ describe('Functions', () => { }); 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', + $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, @@ -196,9 +196,9 @@ describe('Functions', () => { }); 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', + $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, @@ -255,9 +255,9 @@ describe('Functions', () => { }); 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', + $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', @@ -300,9 +300,9 @@ describe('Functions', () => { }); 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', + $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', @@ -344,9 +344,9 @@ describe('Functions', () => { }); 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', + $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', @@ -392,9 +392,9 @@ describe('Functions', () => { }); 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', + $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', @@ -437,9 +437,9 @@ describe('Functions', () => { }); 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', + $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', @@ -507,9 +507,9 @@ describe('Functions', () => { }); 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', + $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', @@ -564,10 +564,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -593,10 +593,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -651,9 +651,9 @@ describe('Functions', () => { }); 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', + $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, @@ -675,9 +675,9 @@ describe('Functions', () => { }); 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', + $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, @@ -697,9 +697,9 @@ describe('Functions', () => { }); 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', + $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, diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 25df258..3ffc4e3 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -26,9 +26,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -51,9 +51,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -72,9 +72,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -93,9 +93,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -114,9 +114,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -135,9 +135,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -156,9 +156,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -177,9 +177,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -198,9 +198,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -255,9 +255,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -277,9 +277,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -299,9 +299,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -318,9 +318,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -337,9 +337,9 @@ describe('Messaging', () => { }); test('test method createAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -359,9 +359,9 @@ describe('Messaging', () => { }); test('test method updateAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -379,9 +379,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -401,9 +401,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -423,9 +423,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -442,9 +442,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -461,9 +461,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -483,9 +483,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -502,9 +502,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -524,9 +524,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -543,9 +543,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -565,9 +565,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -584,9 +584,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -606,9 +606,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -626,9 +626,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -648,9 +648,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -667,9 +667,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -690,9 +690,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -713,9 +713,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -732,9 +732,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -751,9 +751,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -773,9 +773,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -793,9 +793,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -815,9 +815,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -835,9 +835,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -857,9 +857,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -876,9 +876,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -898,9 +898,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -917,9 +917,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -959,9 +959,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -978,9 +978,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -997,9 +997,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -1039,9 +1039,9 @@ describe('Messaging', () => { }); 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', + $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', @@ -1063,9 +1063,9 @@ describe('Messaging', () => { }); 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', + $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', diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..9430d54 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -26,21 +26,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mongo', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mongo', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mongo', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mongo', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mongo', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mongo', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -586,21 +566,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -647,21 +623,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -712,21 +684,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -829,17 +797,13 @@ describe('Mongo', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -852,17 +816,13 @@ describe('Mongo', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -876,6 +836,28 @@ describe('Mongo', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -900,21 +882,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..29ef428 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -26,21 +26,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mysql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mysql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mysql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mysql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mysql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mysql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -603,21 +583,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -664,21 +640,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -729,21 +701,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -888,17 +856,13 @@ describe('Mysql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -911,17 +875,13 @@ describe('Mysql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -935,6 +895,28 @@ describe('Mysql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -959,21 +941,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 476045a..79d73e5 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -70,9 +70,9 @@ describe('Oauth2', () => { }); 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', + $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: [], @@ -94,9 +94,9 @@ describe('Oauth2', () => { }); 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', + $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: [], diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..e955287 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -13,9 +13,9 @@ describe('Organization', () => { 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', + $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: {}, @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -46,9 +39,9 @@ describe('Organization', () => { }); 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', + $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: {}, @@ -57,13 +50,6 @@ describe('Organization', () => { 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', @@ -102,9 +88,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -122,9 +108,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -143,9 +129,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -188,9 +174,9 @@ describe('Organization', () => { }); 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', + $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', @@ -214,9 +200,9 @@ describe('Organization', () => { }); 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', + $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', @@ -240,9 +226,9 @@ describe('Organization', () => { }); 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', + $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', @@ -292,9 +278,9 @@ describe('Organization', () => { }); 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', + $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', @@ -332,9 +318,9 @@ describe('Organization', () => { }); 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', + $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', @@ -369,9 +355,9 @@ describe('Organization', () => { }); 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', + $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', @@ -432,9 +418,9 @@ describe('Organization', () => { }); test('test method createEphemeralProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -456,9 +442,9 @@ describe('Organization', () => { }); test('test method getProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -479,9 +465,9 @@ describe('Organization', () => { }); test('test method updateProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..3b5fe88 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -26,21 +26,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Postgresql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Postgresql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Postgresql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Postgresql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Postgresql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -445,21 +433,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,21 +490,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -570,8 +550,8 @@ describe('Postgresql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -623,21 +603,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -687,21 +663,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -751,21 +723,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -812,21 +780,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -877,21 +841,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1039,17 +999,13 @@ describe('Postgresql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1062,17 +1018,13 @@ describe('Postgresql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1086,6 +1038,28 @@ describe('Postgresql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -1110,21 +1084,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/presences.test.js b/test/services/presences.test.js index b388216..ee08169 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -26,10 +26,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -43,10 +43,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -64,10 +64,10 @@ describe('Presences', () => { }); 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': [], + $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', }; diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..13066dc 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -13,9 +13,9 @@ describe('Project', () => { 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', + $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', @@ -60,9 +60,9 @@ describe('Project', () => { }); 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', + $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', @@ -95,6 +95,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment('<ENVIRONMENT_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment('<ENVIRONMENT_ID>'); + + // 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, @@ -110,9 +250,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -130,9 +270,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -150,9 +290,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -180,9 +320,9 @@ describe('Project', () => { }); 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', + $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', @@ -232,8 +372,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -247,8 +387,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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'); @@ -262,8 +402,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -298,9 +438,9 @@ describe('Project', () => { }); 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', + $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', @@ -338,7 +478,7 @@ describe('Project', () => { }); test('test method updateOAuth2Amazon()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', @@ -355,7 +495,7 @@ describe('Project', () => { }); test('test method updateOAuth2Apple()', async () => { const data = { - '\\$id': 'apple', + $id: 'apple', enabled: true, serviceId: 'ip.appwrite.app.web', keyId: 'P4000000N8', @@ -374,7 +514,7 @@ describe('Project', () => { }); test('test method updateOAuth2Appwrite()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a42000000000000b5a0', clientSecret: @@ -390,7 +530,7 @@ describe('Project', () => { }); test('test method updateOAuth2Auth0()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'OaOkIA000000000000000000005KLSYq', clientSecret: @@ -408,7 +548,7 @@ describe('Project', () => { }); test('test method updateOAuth2Authentik()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dTKOPa0000000000000000000000000000e7G8hv', clientSecret: @@ -425,7 +565,7 @@ describe('Project', () => { }); test('test method updateOAuth2Autodesk()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '5zw90v00000000000000000000kVYXN7', clientSecret: '7I000000000000MW', @@ -440,7 +580,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitbucket()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, key: 'Knt70000000000ByRc', secret: 'NMfLZJ00000000000000000000TLQdDx', @@ -455,7 +595,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitly()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'd95151000000000000000000000000000067af9b', clientSecret: 'a13e250000000000000000000000000000d73095', @@ -470,7 +610,7 @@ describe('Project', () => { }); test('test method updateOAuth2Box()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'deglcs00000000000000000000x2og6y', clientSecret: 'OKM1f100000000000000000000eshEif', @@ -485,7 +625,7 @@ describe('Project', () => { }); test('test method updateOAuth2Cloudflare()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '4b866000000000000000000000c9e4e2', clientSecret: @@ -501,7 +641,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dailymotion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, apiKey: '07a9000000000000067f', apiSecret: 'a399a90000000000000000000000000000d90639', @@ -516,7 +656,7 @@ describe('Project', () => { }); test('test method updateOAuth2Discord()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '950722000000343754', clientSecret: 'YmPXnM000000000000000000002zFg5D', @@ -532,7 +672,7 @@ describe('Project', () => { }); test('test method updateOAuth2Disqus()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, publicKey: 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', @@ -549,7 +689,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dropbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appKey: 'jl000000000009t', appSecret: 'g200000000000vw', @@ -564,7 +704,7 @@ describe('Project', () => { }); test('test method updateOAuth2Etsy()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, keyString: 'nsgzxh0000000000008j85a2', sharedSecret: 'tp000000ru', @@ -579,7 +719,7 @@ describe('Project', () => { }); test('test method updateOAuth2Facebook()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appId: '260600000007694', appSecret: '2d0b2800000000000000000000d38af4', @@ -594,7 +734,7 @@ describe('Project', () => { }); test('test method updateOAuth2Figma()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'byay5H0000000000VtiI40', clientSecret: 'yEpOYn0000000000000000004iIsU5', @@ -609,7 +749,7 @@ describe('Project', () => { }); test('test method updateOAuth2FusionAuth()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'b2222c00-0000-0000-0000-000000862097', clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', @@ -625,7 +765,7 @@ describe('Project', () => { }); test('test method updateOAuth2GitHub()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'e4d87900000000540733', clientSecret: '5e07c00000000000000000000000000000198bcc', @@ -641,7 +781,7 @@ describe('Project', () => { }); test('test method updateOAuth2Gitlab()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', @@ -658,7 +798,7 @@ describe('Project', () => { }); test('test method updateOAuth2Google()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', @@ -677,7 +817,7 @@ describe('Project', () => { }); test('test method updateOAuth2HuggingFace()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', @@ -692,7 +832,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kakao()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -708,7 +848,7 @@ describe('Project', () => { }); test('test method updateOAuth2Keycloak()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-o0000000st-app', clientSecret: 'jdjrJd00000000000000000000HUsaZO', @@ -725,7 +865,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kick()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '01KQ7C00000000000001MFHS32', clientSecret: @@ -741,7 +881,7 @@ describe('Project', () => { }); test('test method updateOAuth2Linkedin()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '770000000000dv', primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', @@ -756,7 +896,7 @@ describe('Project', () => { }); test('test method updateOAuth2Microsoft()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', @@ -773,7 +913,7 @@ describe('Project', () => { }); test('test method updateOAuth2Notion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauthClientId: '341d8700-0000-0000-0000-000000446ee3', oauthClientSecret: @@ -789,7 +929,7 @@ describe('Project', () => { }); test('test method updateOAuth2Oidc()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'qibI2x0000000000000000000000000006L2YFoG', clientSecret: @@ -811,7 +951,7 @@ describe('Project', () => { }); test('test method updateOAuth2Okta()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '0oa00000000000000698', clientSecret: @@ -830,7 +970,7 @@ describe('Project', () => { }); test('test method updateOAuth2Paypal()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -847,7 +987,7 @@ describe('Project', () => { }); test('test method updateOAuth2PaypalSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -864,7 +1004,7 @@ describe('Project', () => { }); test('test method updateOAuth2Podio()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-oauth-test-app', clientSecret: @@ -880,7 +1020,7 @@ describe('Project', () => { }); test('test method updateOAuth2Resend()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', clientSecret: @@ -896,7 +1036,7 @@ describe('Project', () => { }); test('test method updateOAuth2Salesforce()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', @@ -913,7 +1053,7 @@ describe('Project', () => { }); test('test method updateOAuth2Slack()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '23000000089.15000000000023', clientSecret: '81656000000000000000000000f3d2fd', @@ -928,7 +1068,7 @@ describe('Project', () => { }); test('test method updateOAuth2Spotify()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6ec271000000000000000000009beace', clientSecret: 'db068a000000000000000000008b5b9f', @@ -943,7 +1083,7 @@ describe('Project', () => { }); test('test method updateOAuth2Stripe()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'ca_UKibXX0000000000000000000006byvR', apiSecretKey: @@ -959,7 +1099,7 @@ describe('Project', () => { }); test('test method updateOAuth2TikTok()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'awz000000000tyw0', clientSecret: '6wXewM00000000000000000000yXnite', @@ -974,7 +1114,7 @@ describe('Project', () => { }); test('test method updateOAuth2Tradeshift()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -989,7 +1129,7 @@ describe('Project', () => { }); test('test method updateOAuth2TradeshiftSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -1004,7 +1144,7 @@ describe('Project', () => { }); test('test method updateOAuth2Twitch()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'vvi0in000000000000000000ikmt9p', clientSecret: 'pmapue000000000000000000zylw3v', @@ -1019,7 +1159,7 @@ describe('Project', () => { }); test('test method updateOAuth2Webflow()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '8bb20000000000000000000000000000000000000000000000000000000040dd', @@ -1036,7 +1176,7 @@ describe('Project', () => { }); test('test method updateOAuth2WordPress()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '130005', clientSecret: @@ -1052,7 +1192,7 @@ describe('Project', () => { }); test('test method updateOAuth2X()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: 'slzZV0000000000000NFLaWT', secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', @@ -1067,7 +1207,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yahoo()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', @@ -1083,7 +1223,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yandex()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a8a6a0000000000000000000091483c', clientSecret: 'bbf98500000000000000000000c75a63', @@ -1098,7 +1238,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoho()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '1000.83C178000000000000000000RPNX0B', clientSecret: 'fb5cac000000000000000000000000000000a68f6e', @@ -1114,7 +1254,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoom()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'QMAC00000000000000w0AQ', clientSecret: 'GAWsG4000000000000000000007U01ON', @@ -1129,7 +1269,7 @@ describe('Project', () => { }); test('test method getOAuth2Provider()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -1158,12 +1298,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1179,12 +1320,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1200,9 +1342,9 @@ describe('Project', () => { }); 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', + $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', @@ -1221,9 +1363,9 @@ describe('Project', () => { }); 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', + $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', @@ -1242,9 +1384,9 @@ describe('Project', () => { }); 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', + $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', @@ -1263,9 +1405,9 @@ describe('Project', () => { }); 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', + $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', @@ -1284,9 +1426,9 @@ describe('Project', () => { }); 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', + $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', @@ -1305,9 +1447,9 @@ describe('Project', () => { }); 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', + $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', @@ -1326,9 +1468,9 @@ describe('Project', () => { }); 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', + $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', @@ -1347,9 +1489,9 @@ describe('Project', () => { }); 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', + $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', @@ -1368,9 +1510,9 @@ describe('Project', () => { }); 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', + $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', @@ -1408,9 +1550,9 @@ describe('Project', () => { }); 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', + $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', @@ -1445,9 +1587,9 @@ describe('Project', () => { }); 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', + $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', @@ -1482,9 +1624,9 @@ describe('Project', () => { }); 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', + $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', @@ -1519,9 +1661,9 @@ describe('Project', () => { }); 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', + $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', @@ -1556,9 +1698,9 @@ describe('Project', () => { }); 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', + $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', @@ -1593,9 +1735,9 @@ describe('Project', () => { }); 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', + $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', @@ -1628,11 +1770,48 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy('<RP_ID>'); + + // 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', + $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', @@ -1667,9 +1846,9 @@ describe('Project', () => { }); 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', + $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', @@ -1704,9 +1883,9 @@ describe('Project', () => { }); 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', + $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', @@ -1741,9 +1920,9 @@ describe('Project', () => { }); test('test method updatePasswordPwnedPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -1776,9 +1955,46 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', + $id: 'password-dictionary', min: 12, uppercase: true, lowercase: true, @@ -1795,9 +2011,9 @@ describe('Project', () => { }); 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', + $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', @@ -1832,9 +2048,9 @@ describe('Project', () => { }); 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', + $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', @@ -1869,9 +2085,9 @@ describe('Project', () => { }); 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', + $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', @@ -1906,9 +2122,9 @@ describe('Project', () => { }); 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', + $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', @@ -1943,9 +2159,9 @@ describe('Project', () => { }); 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', + $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', @@ -1980,8 +2196,9 @@ describe('Project', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', - enabled: true, + $id: 'password-dictionary', + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); @@ -1993,9 +2210,9 @@ describe('Project', () => { }); 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', + $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', @@ -2030,9 +2247,9 @@ describe('Project', () => { }); 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', + $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', @@ -2067,9 +2284,9 @@ describe('Project', () => { }); 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', + $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', @@ -2178,9 +2395,9 @@ describe('Project', () => { }); 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', + $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, @@ -2201,9 +2418,9 @@ describe('Project', () => { }); 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', + $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, @@ -2220,9 +2437,9 @@ describe('Project', () => { }); 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', + $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, diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js index bf9d288..3445b18 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -41,9 +41,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -55,6 +55,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createAPIRule('example.com'); @@ -66,9 +67,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -80,6 +81,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createFunctionRule( @@ -94,9 +96,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -108,6 +110,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createRedirectRule( @@ -125,9 +128,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -139,6 +142,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createSiteRule('example.com', '<SITE_ID>'); @@ -148,11 +152,40 @@ describe('Proxy', () => { expect(response).toEqual(data); }); + test('test method createSMTPRule()', 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', + protocol: 'http', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await proxy.createSMTPRule( + 'example.com', + '<FUNCTION_ID>', + ); + + // 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', + $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', @@ -164,6 +197,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.getRule('<RULE_ID>'); @@ -185,9 +219,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -199,6 +233,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.updateRuleStatus('<RULE_ID>'); diff --git a/test/services/sites.test.js b/test/services/sites.test.js index 8e558d9..cf30e82 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -27,9 +27,9 @@ describe('Sites', () => { }); 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', + $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, @@ -104,9 +104,9 @@ describe('Sites', () => { }); 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', + $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, @@ -150,9 +150,9 @@ describe('Sites', () => { }); 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', + $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, @@ -206,9 +206,9 @@ describe('Sites', () => { }); 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', + $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, @@ -268,9 +268,9 @@ describe('Sites', () => { }); 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', + $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', @@ -312,9 +312,9 @@ describe('Sites', () => { }); 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', + $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', @@ -356,9 +356,9 @@ describe('Sites', () => { }); 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', + $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', @@ -404,9 +404,9 @@ describe('Sites', () => { }); 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', + $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', @@ -449,9 +449,9 @@ describe('Sites', () => { }); 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', + $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', @@ -519,9 +519,9 @@ describe('Sites', () => { }); 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', + $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', @@ -576,10 +576,10 @@ describe('Sites', () => { }); 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': [], + $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', @@ -628,9 +628,9 @@ describe('Sites', () => { }); 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', + $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, @@ -652,9 +652,9 @@ describe('Sites', () => { }); 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', + $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, @@ -671,9 +671,9 @@ describe('Sites', () => { }); 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', + $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, diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 7f35319..b46b168 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -27,10 +27,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -52,10 +52,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -77,10 +77,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -125,11 +125,11 @@ describe('Storage', () => { }); test('test method createFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -156,11 +156,11 @@ describe('Storage', () => { }); test('test method getFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -183,11 +183,11 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..6320233 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -26,10 +26,10 @@ describe('TablesDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('TablesDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('TablesDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,21 +191,17 @@ describe('TablesDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -265,9 +261,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -296,9 +292,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -340,9 +336,9 @@ describe('TablesDB', () => { }); test('test method createCutover()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -436,10 +432,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -463,10 +459,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -486,10 +482,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -546,8 +542,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -569,8 +565,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -593,8 +589,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -616,8 +612,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -640,8 +636,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -664,8 +660,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -689,8 +685,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -713,8 +709,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -738,8 +734,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -764,8 +760,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -791,8 +787,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -814,8 +810,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -838,8 +834,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -861,8 +857,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -885,8 +881,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -909,8 +905,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -934,8 +930,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -957,8 +953,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -980,8 +976,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1003,8 +999,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1027,8 +1023,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1050,8 +1046,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1074,8 +1070,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1097,8 +1093,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1120,8 +1116,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1143,8 +1139,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1166,8 +1162,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1195,8 +1191,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1223,8 +1219,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1248,8 +1244,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1273,8 +1269,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1296,8 +1292,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1320,8 +1316,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1344,8 +1340,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1369,8 +1365,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1394,8 +1390,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1419,8 +1415,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1467,9 +1463,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1493,9 +1489,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1544,13 +1540,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1633,13 +1629,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1655,13 +1651,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1677,13 +1673,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1713,13 +1709,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1736,13 +1732,13 @@ describe('TablesDB', () => { }); 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': [], + $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( diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 7dcf744..0248491 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -26,9 +26,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -43,9 +43,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -60,9 +60,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -100,9 +100,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -123,9 +123,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -146,9 +146,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -195,9 +195,9 @@ describe('Teams', () => { }); 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', + $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', @@ -221,9 +221,9 @@ describe('Teams', () => { }); 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', + $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', @@ -250,9 +250,9 @@ describe('Teams', () => { }); 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', + $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', @@ -293,9 +293,9 @@ describe('Teams', () => { }); 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', + $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', diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index 323ab93..1850b2e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -26,8 +26,8 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -47,8 +47,8 @@ describe('Tokens', () => { }); test('test method get()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -65,8 +65,8 @@ describe('Tokens', () => { }); test('test method update()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..21befd9 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -26,9 +26,9 @@ describe('Users', () => { }); 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', + $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, @@ -53,9 +53,9 @@ describe('Users', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Users', () => { }); 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', + $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, @@ -138,9 +138,9 @@ describe('Users', () => { }); 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', + $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, @@ -169,9 +169,9 @@ describe('Users', () => { }); 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', + $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, @@ -200,9 +200,9 @@ describe('Users', () => { }); 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', + $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, @@ -236,9 +236,9 @@ describe('Users', () => { }); 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', + $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, @@ -270,9 +270,9 @@ describe('Users', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Users', () => { }); 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', + $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, @@ -338,9 +338,9 @@ describe('Users', () => { }); 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', + $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, @@ -368,9 +368,9 @@ describe('Users', () => { }); 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', + $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, @@ -407,9 +407,9 @@ describe('Users', () => { }); 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', + $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, @@ -447,9 +447,9 @@ describe('Users', () => { }); 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', + $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, @@ -474,9 +474,9 @@ describe('Users', () => { }); 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', + $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, @@ -527,8 +527,8 @@ describe('Users', () => { }); test('test method getMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', code: '446372', @@ -650,9 +650,9 @@ describe('Users', () => { }); 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', + $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, @@ -675,11 +675,70 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys('<USER_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('<USER_ID>', '<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '<USER_ID>', + '<PASSKEY_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('<USER_ID>', '<PASSKEY_ID>'); + + // 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', + $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, @@ -704,9 +763,9 @@ describe('Users', () => { }); 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', + $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, @@ -764,9 +823,9 @@ describe('Users', () => { }); 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', + $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', @@ -824,9 +883,9 @@ describe('Users', () => { }); 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', + $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, @@ -864,9 +923,9 @@ describe('Users', () => { }); 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', + $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', @@ -888,9 +947,9 @@ describe('Users', () => { }); 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', + $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', @@ -907,9 +966,9 @@ describe('Users', () => { }); 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', + $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', @@ -936,8 +995,8 @@ describe('Users', () => { }); test('test method createToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -953,9 +1012,9 @@ describe('Users', () => { }); 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', + $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, @@ -980,9 +1039,9 @@ describe('Users', () => { }); 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', + $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, diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..4fe8681 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -26,10 +26,10 @@ describe('VectorsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('VectorsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('VectorsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -204,10 +204,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -260,10 +260,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -317,13 +317,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -422,13 +422,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -444,13 +444,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -466,13 +466,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -518,9 +518,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -544,9 +544,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -582,21 +582,17 @@ describe('VectorsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..1e672a2 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('<RULE_ID>', 'api', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '<RULE_ID>', + 'api', + '<NAME>', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '<RULE_ID>', + 'api', + '<NAME>', + '<LOCATION>', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule('<RULE_ID>'); + + // 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 7f7e54b..d232fb5 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -26,9 +26,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -55,9 +55,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -79,9 +79,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -118,9 +118,9 @@ describe('Webhooks', () => { }); 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', + $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: [], diff --git a/test/topic.test.js b/test/topic.test.js index 44ba8cd..71912d2 100644 --- a/test/topic.test.js +++ b/test/topic.test.js @@ -9,24 +9,10 @@ describe('Topic', () => { expect(Topic.path(['user']).path(['notification']).toString()).toEqual( 'user/notification', ); - }); - test('any', () => { - expect( - Topic.path(['user']).any().path(['notification']).toString(), - ).toEqual('user/+/notification'); - expect( - Topic.path(['chat']).any().any().path(['message']).toString(), - ).toEqual('chat/+/+/message'); - expect(Topic.any().path(['notification']).toString()).toEqual( - '+/notification', + expect(Topic.path(['org', '42']).path(['logs']).toString()).toEqual( + 'org/42/logs', ); }); - test('all', () => { - expect( - Topic.path(['org']).any().path(['logs']).all().toString(), - ).toEqual('org/+/logs/#'); - expect(Topic.all().toString()).toEqual('#'); - }); test.each([ ['an empty path', []], ['an empty level', ['user', '']], @@ -39,6 +25,6 @@ describe('Topic', () => { ['a non-array', 'user'], ])('rejects %s', (_, levels) => { expect(() => Topic.path(levels)).toThrow(Error); - expect(() => Topic.any().path(levels)).toThrow(Error); + expect(() => Topic.path(['user']).path(levels)).toThrow(Error); }); }); From 6a35b330e1b209a18e84d2458a8a405068e4de7e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal <chiragaggarwal5k@gmail.com> Date: Thu, 15 Oct 2026 12:51:14 +0100 Subject: [PATCH 6/7] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 88 +- README.md | 58 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/domains/get-price.md | 2 +- docs/examples/domains/list-prices.md | 2 +- docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 2 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/update-email.md | 10 +- docs/examples/messaging/update-push.md | 4 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/mongo/create-restoration.md | 3 + docs/examples/mongo/promote-restoration.md | 15 + docs/examples/mysql/create-restoration.md | 3 + docs/examples/mysql/promote-restoration.md | 15 + docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../examples/postgresql/create-restoration.md | 3 + .../postgresql/promote-restoration.md | 15 + .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 +- .../project/update-o-auth-2-auth-0.md | 2 +- .../project/update-o-auth-2-discord.md | 2 +- .../project/update-o-auth-2-git-hub.md | 2 +- .../project/update-o-auth-2-google.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 2 +- .../project/update-o-auth-2-microsoft.md | 2 +- docs/examples/project/update-o-auth-2-okta.md | 2 +- .../project/update-o-auth-2-salesforce.md | 2 +- docs/examples/project/update-o-auth-2-zoho.md | 2 +- .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/proxy/create-smtp-rule.md | 16 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 88 +- src/enums/databases-index-type.ts | 1 + src/enums/execution-trigger.ts | 1 + src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/proxy-rule-protocol.ts | 4 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 15 +- src/models.ts | 1150 ++- src/query.ts | 809 ++ src/services/account.ts | 2254 ++++- src/services/activities.ts | 102 +- src/services/advisor.ts | 229 +- src/services/apps.ts | 633 +- src/services/backups.ts | 355 +- src/services/databases.ts | 3189 +++++-- src/services/documents-db.ts | 1179 ++- src/services/domains.ts | 1398 ++- src/services/embeddings.ts | 35 +- src/services/functions.ts | 1077 ++- src/services/locale.ts | 211 +- src/services/messaging.ts | 3171 ++++--- src/services/mongo.ts | 1826 +++- src/services/mysql.ts | 2084 ++++- src/services/oauth-2.ts | 359 +- src/services/organization.ts | 735 +- src/services/postgresql.ts | 2229 ++++- src/services/presences.ts | 94 +- src/services/project.ts | 7877 +++++++++++++---- src/services/proxy.ts | 340 +- src/services/sites.ts | 979 +- src/services/storage.ts | 326 +- src/services/tables-db.ts | 3648 ++++++-- src/services/teams.ts | 380 +- src/services/tokens.ts | 142 +- src/services/users.ts | 1808 +++- src/services/vectors-db.ts | 1181 ++- src/services/waf.ts | 2415 +++++ src/services/webhooks.ts | 217 +- src/topic.ts | 51 +- test/client.test.js | 53 + test/query.test.js | 463 +- test/services/account.test.js | 329 +- test/services/activities.test.js | 2 +- test/services/advisor.test.js | 12 +- test/services/apps.test.js | 60 +- test/services/avatars.test.js | 6 +- test/services/backups.test.js | 42 +- test/services/databases.test.js | 310 +- test/services/documents-d-b.test.js | 172 +- test/services/domains.test.js | 162 +- test/services/functions.test.js | 98 +- test/services/messaging.test.js | 282 +- test/services/mongo.test.js | 162 +- test/services/mysql.test.js | 162 +- test/services/oauth2.test.js | 12 +- test/services/organization.test.js | 98 +- test/services/postgresql.test.js | 182 +- test/services/presences.test.js | 24 +- test/services/project.test.js | 569 +- test/services/proxy.test.js | 71 +- test/services/sites.test.js | 86 +- test/services/storage.test.js | 48 +- test/services/tables-d-b.test.js | 338 +- test/services/teams.test.js | 60 +- test/services/tokens.test.js | 12 +- test/services/users.test.js | 211 +- test/services/vectors-d-b.test.js | 144 +- test/services/waf.test.js | 354 + test/services/webhooks.test.js | 24 +- test/topic.test.js | 21 +- 143 files changed, 39225 insertions(+), 8784 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/mongo/promote-restoration.md create mode 100644 docs/examples/mysql/promote-restoration.md create mode 100644 docs/examples/postgresql/promote-restoration.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/proxy/create-smtp-rule.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/proxy-rule-protocol.ts create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..b02f189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,70 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - ## 30.0.0 -* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed -* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed -* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` -* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model -* Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `account.createIdTokenSession` and email verification and recovery OTP methods +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models +* Breaking: removed `organization.createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `organization.listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead +* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys` +* Breaking: removed `BillingPlanGroup.Starter`; use `BillingPlanGroup.Free` +* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `string[]` +* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage` +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `mongo`, `mysql` and `postgresql` `promoteRestoration`, `restoreMode`, `targetName` and `autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration.restoreMode` +* Added: `proxy.createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule.protocol` +* Added: `emailEnabled` on `functions.update` and `Function`, and `ExecutionTrigger.Email` +* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page` +* Added: `Query.builder()` to chain queries into a list +* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider +* Updated: missing response fields fall back to their documented defaults +* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned +* Fixed: list and object defaults filled into a response are copied per model, and object defaults are `{}` instead of `[]` + +## 29.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers -* Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics -* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + +## 29.3.1 + +* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys +* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy + +## 29.3.0 + +* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification` +* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in +* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey` +* Added: `project.updatePasskeyPolicy` to configure passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..a2881b8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) @@ -50,7 +50,13 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```js let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -73,7 +79,13 @@ client ; let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -84,11 +96,11 @@ promise.then(function (response) { ### Type Safety with Models -The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. +The Appwrite Node SDK provides type safety when working with table rows through generic methods. Methods like `listRows`, `getRow`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. **TypeScript:** ```typescript -interface Book { +interface Book extends Models.Row { name: string; author: string; releaseYear?: string; @@ -97,15 +109,15 @@ interface Book { isCheckedOut: boolean; } -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - const documents = await databases.listDocuments<Book>( - 'your-database-id', - 'your-collection-id' - ); + const result = await tablesDB.listRows<Book>({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety }); } catch (error) { @@ -125,16 +137,16 @@ try { * @property {boolean} isCheckedOut */ -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - /** @type {Models.DocumentList<Book>} */ - const documents = await databases.listDocuments( - 'your-database-id', - 'your-collection-id' - ); + /** @type {Models.RowList<Book>} */ + const result = await tablesDB.listRows({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE }); } catch (error) { @@ -152,7 +164,13 @@ The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` a let users = new sdk.Users(client); try { - let res = await users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); + let res = await users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); } catch(e) { console.log(e.message); } diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '<STATE>', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '<PASSKEY_ID>', // optional + name: '<NAME>', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '<CHALLENGE_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '<PASSKEY_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index ff77675..893f3f0 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.getPrice({ domain: 'example.com', - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index bcf3572..86de02c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.listPrices({ domains: [], - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..a9c4c9d 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,7 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional + emailEnabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 499e392..256234c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -18,10 +18,10 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional - replyToEmail: 'email@example.com', // optional - replyToName: '<REPLY_TO_NAME>', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 04e86f7..0fc7a9a 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -10,18 +10,18 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateEmail({ messageId: '<MESSAGE_ID>', - subject: '<SUBJECT>', // optional - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional cc: [], // optional bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional replyToEmail: 'email@example.com', // optional replyToName: '<REPLY_TO_NAME>', // optional - draft: false, // optional - html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index d62e346..5d0e6b7 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -10,11 +10,11 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updatePush({ messageId: '<MESSAGE_ID>', - title: '<TITLE>', // optional - body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional data: {}, // optional action: '<ACTION>', // optional image: '<ID1:ID2>', // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 7c95f4f..940474a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,10 +10,10 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + content: '<CONTENT>', // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 7a6f1a3..326620f 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -14,5 +14,8 @@ const result = await mongo.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mongo/promote-restoration.md b/docs/examples/mongo/promote-restoration.md new file mode 100644 index 0000000..dc19b5c --- /dev/null +++ b/docs/examples/mongo/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mongo = new sdk.Mongo(client); + +const result = await mongo.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index 6e95f01..9e4843c 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -14,5 +14,8 @@ const result = await mysql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mysql/promote-restoration.md b/docs/examples/mysql/promote-restoration.md new file mode 100644 index 0000000..8aa43ed --- /dev/null +++ b/docs/examples/mysql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mysql = new sdk.Mysql(client); + +const result = await mysql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '<CLIENT_ID>', // optional scope: '<SCOPE>', // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '<CLIENT_SECRET>', // optional codeVerifier: '<CODE_VERIFIER>', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index 5cc8ea0..9647966 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -14,5 +14,8 @@ const result = await postgresql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/postgresql/promote-restoration.md b/docs/examples/postgresql/promote-restoration.md new file mode 100644 index 0000000..48e87af --- /dev/null +++ b/docs/examples/postgresql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const postgresql = new sdk.Postgresql(client); + +const result = await postgresql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..c0add3b --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..5400831 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..417f5c8 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..88d3d57 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..14bb9a8 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 9319a90..e1392e0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,8 +13,8 @@ const result = await project.updateOAuth2Apple({ keyId: '<KEY_ID>', // optional teamId: '<TEAM_ID>', // optional p8File: '<P8_FILE>', // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 61fb73c..79ba89d 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional endpoint: '<ENDPOINT>', // optional - prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index d76ac95..a8d5282 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index cb497db..8d3fbdd 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 0325eef..fc081aa 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,8 +12,8 @@ const result = await project.updateOAuth2Google({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index cb310ae..af88267 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kakao({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7a7edb2..2cb3efe 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '<APPLICATION_ID>', // optional applicationSecret: '<APPLICATION_SECRET>', // optional tenant: '<TENANT>', // optional - prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 4b6deba..7f0052b 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -13,7 +13,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '<CLIENT_SECRET>', // optional domain: 'example.com', // optional authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional - prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 12698d0..ffd57c0 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '<CUSTOMER_KEY>', // optional customerSecret: '<CUSTOMER_SECRET>', // optional - prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index baa7bc8..2ccc10d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '<RP_ID>', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/proxy/create-smtp-rule.md b/docs/examples/proxy/create-smtp-rule.md new file mode 100644 index 0000000..28691f6 --- /dev/null +++ b/docs/examples/proxy/create-smtp-rule.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const proxy = new sdk.Proxy(client); + +const result = await proxy.createSMTPRule({ + domain: 'example.com', + functionId: '<FUNCTION_ID>', + branch: '<BRANCH>', // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..2d45ad5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional + membershipId: '<MEMBERSHIP_ID>', // optional }); ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '<USER_ID>', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + location: '<LOCATION>', + statusCode: 300, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + location: '<LOCATION>', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..b36b64e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..9272cdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..041b3ef 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { fetch, FormData, File, Agent, type RequestInit } from 'undici'; import { Models } from './models'; import { InputFile } from './inputFile'; +import { flattenParam } from './query'; import JSONbigModule from 'json-bigint'; const JSONbigParser = JSONbigModule({ storeAsString: false }); const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true }); @@ -44,6 +45,79 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record<string, unknown>; + properties?: Record<string, DefaultsShape>; +}; + +type Defaults = { + root: DefaultsShape; + models: Record<string, DefaultsModel>; +}; + +export function applyDefaults<T>(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function cloneDefault(value: unknown): unknown { + if (Array.isArray(value)) { + return value.map(cloneDefault); + } + if (typeof value === 'object' && value !== null) { + const copy: Record<string, unknown> = {}; + for (const [key, member] of Object.entries(value)) { + copy[key] = cloneDefault(member); + } + return copy; + } + return value; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record<string, DefaultsModel>, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record<string, unknown> = { ...model.defaults, ...value }; + // Each item gets its own copy of a filled-in list or object, so mutating one doesn't change the rest + for (const key of Object.keys(model.defaults ?? {})) { + if (!Object.prototype.hasOwnProperty.call(value, key)) { + result[key] = cloneDefault(result[key]); + } + } + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + // The spread drops the non-enumerable JSON toString that Client.call attaches. + if (Object.prototype.hasOwnProperty.call(value, 'toString')) { + Object.defineProperty(result, 'toString', { + value: () => JSONbig.stringify(result), + writable: true, + enumerable: false, + configurable: true, + }); + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +154,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +215,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.0', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.5.0', }; /** @@ -394,6 +468,10 @@ class Client { ): { uri: string; options: RequestInit } { method = method.toUpperCase(); + for (const key of Object.keys(params)) { + params[key] = flattenParam(params[key]); + } + headers = Object.assign({}, this.headers, headers); const options: RequestInit = { @@ -887,6 +965,6 @@ class Client { } export { Client, AppwriteException }; -export { Query } from './query'; +export { Query, QueryBuilder, flattenParam } from './query'; export type { Models, Payload, UploadProgress }; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833..275668e 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts index 84fa8f6..b16a878 100644 --- a/src/enums/execution-trigger.ts +++ b/src/enums/execution-trigger.ts @@ -2,4 +2,5 @@ export enum ExecutionTrigger { Http = 'http', Schedule = 'schedule', Event = 'event', + Email = 'email', } diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/proxy-rule-protocol.ts b/src/enums/proxy-rule-protocol.ts new file mode 100644 index 0000000..1ed23de --- /dev/null +++ b/src/enums/proxy-rule-protocol.ts @@ -0,0 +1,4 @@ +export enum ProxyRuleProtocol { + Http = 'http', + Smtp = 'smtp', +} diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4..09fd95c 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..e0da2f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,10 @@ -export { Client, Query, AppwriteException } from './client'; +export { + Client, + Query, + QueryBuilder, + flattenParam, + AppwriteException, +} from './client'; export { Account } from './services/account'; export { Activities } from './services/activities'; export { Apps } from './services/apps'; @@ -28,13 +34,14 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; -export { Topic, ResolvedTopic } from './topic'; +export { Topic } from './topic'; export { Operator, Condition } from './operator'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; @@ -116,6 +123,8 @@ export { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; export { PlatformType } from './enums/platform-type'; export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; export { ProxyRuleStatus } from './enums/proxy-rule-status'; +export { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..afb50ff 100644 --- a/src/models.ts +++ b/src/models.ts @@ -22,9 +22,11 @@ import { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; import { PlatformType } from './enums/platform-type'; import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; import { ProxyRuleStatus } from './enums/proxy-rule-status'; +import { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +505,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +517,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -744,39 +748,39 @@ export namespace Models { /** * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ - status?: DatabaseStatus; + status?: DatabaseStatus | null; /** * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ - engine?: string; + engine?: string | null; /** * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. */ - specification?: string; + specification?: string | null; /** * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ - replicas?: number; + replicas?: number | null; /** * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. */ - error?: string; + error?: string | null; /** * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. */ - containerStatus?: string; + containerStatus?: string | null; /** * 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; + lifecycleState?: string | null; /** * Database backup policies. */ - policies?: BackupPolicy[]; + policies?: BackupPolicy[] | null; /** * Database backup archives. */ - archives?: BackupArchive[]; + archives?: BackupArchive[] | null; }; /** @@ -934,7 +938,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -950,11 +954,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -984,7 +988,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -996,15 +1000,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1034,7 +1038,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1046,15 +1050,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -1084,7 +1088,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1096,15 +1100,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1134,7 +1138,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1146,7 +1150,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -1176,7 +1180,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1192,7 +1196,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1222,7 +1226,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1242,7 +1246,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1272,7 +1276,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1288,7 +1292,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1318,7 +1322,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1334,7 +1338,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1364,7 +1368,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1380,7 +1384,7 @@ export namespace Models { /** * Default value for attribute when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -1410,7 +1414,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1472,7 +1476,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1484,7 +1488,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -1514,7 +1518,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1526,7 +1530,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -1556,7 +1560,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1568,7 +1572,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -1598,7 +1602,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1614,11 +1618,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1648,7 +1652,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1660,11 +1664,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1694,7 +1698,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1706,11 +1710,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1740,7 +1744,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1752,11 +1756,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1844,7 +1848,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1882,7 +1886,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -2030,7 +2034,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2046,11 +2050,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2080,7 +2084,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2092,15 +2096,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2130,7 +2134,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2142,15 +2146,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -2180,7 +2184,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2192,15 +2196,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2230,7 +2234,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2242,7 +2246,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -2272,7 +2276,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2288,7 +2292,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2318,7 +2322,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2338,7 +2342,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2368,7 +2372,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2384,7 +2388,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2414,7 +2418,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2430,7 +2434,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2460,7 +2464,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2476,7 +2480,7 @@ export namespace Models { /** * Default value for column when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -2506,7 +2510,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2568,7 +2572,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2580,7 +2584,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -2610,7 +2614,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2622,7 +2626,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -2652,7 +2656,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2664,7 +2668,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -2694,7 +2698,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2710,11 +2714,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2744,7 +2748,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2756,11 +2760,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2790,7 +2794,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2802,11 +2806,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2836,7 +2840,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2848,11 +2852,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2898,7 +2902,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -2944,7 +2948,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -3052,7 +3056,7 @@ export namespace Models { /** * Presence status. */ - status?: string; + status?: string | null; /** * Presence source. */ @@ -3060,7 +3064,7 @@ export namespace Models { /** * Presence expiry date in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * Presence metadata. */ @@ -3092,15 +3096,15 @@ export namespace Models { /** * Hashed user password. */ - password?: string; + password?: string | null; /** * Password hashing algorithm. */ - hash?: string; + hash?: string | null; /** * Password hashing algorithm configuration. */ - hashOptions?: object; + hashOptions?: object | null; /** * User registration date in ISO 8601 format. */ @@ -3132,27 +3136,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3176,11 +3180,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3346,27 +3350,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3390,11 +3394,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3654,47 +3658,47 @@ export namespace Models { /** * City */ - city?: string; + city?: string | null; /** * Name of timezone */ - timeZone?: string; + timeZone?: string | null; /** * Postal code */ - postalCode?: string; + postalCode?: string | null; /** * Latitude */ - latitude?: number; + latitude?: number | null; /** * Longitude */ - longitude?: number; + longitude?: number | null; /** * Autonomous System Number (ASN) of the IP */ - autonomousSystemNumber?: string; + autonomousSystemNumber?: string | null; /** * Organization that owns the ASN */ - autonomousSystemOrganization?: string; + autonomousSystemOrganization?: string | null; /** * Internet service provider of the IP */ - isp?: string; + isp?: string | null; /** * Connection type of the IP (e.g. cable, cellular, corporate) */ - connectionType?: string; + connectionType?: string | null; /** * User type classification of the IP (e.g. residential, business, hosting) */ - connectionUsageType?: string; + connectionUsageType?: string | null; /** * Registered organization of the IP */ - connectionOrganization?: string; + connectionOrganization?: string | null; }; /** @@ -4201,6 +4205,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number | null; /** * Function execution timeout in seconds. */ @@ -4253,6 +4261,10 @@ export namespace Models { * Machine specification for executions. */ runtimeSpecification: string; + /** + * Whether inbound email (SMTP) may trigger this function. Opt-in; default is false. When disabled, recipients for this function are rejected. + */ + emailEnabled: boolean; }; /** @@ -4342,7 +4354,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile?: string; + fallbackFile?: string | null; }; /** @@ -4492,7 +4504,7 @@ export namespace Models { */ deploymentId: string; /** - * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. + * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, `event`, or `email`. */ trigger: ExecutionTrigger; /** @@ -4538,7 +4550,7 @@ export namespace Models { /** * The scheduled time for execution. If left empty, execution will be queued immediately. */ - scheduledAt?: string; + scheduledAt?: string | null; }; /** @@ -4652,87 +4664,91 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled?: boolean; + wafEnabled?: boolean | null; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * First time the project received a non-console API request. Empty until the project is used. */ - firstAccessedAt?: string; + firstAccessedAt?: string | null; /** * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. */ - mcpAccessedAt?: string; + mcpAccessedAt?: string | null; /** * OAuth2 server status */ - oAuth2ServerEnabled?: boolean; + oAuth2ServerEnabled?: boolean | null; /** * OAuth2 server authorization URL */ - oAuth2ServerAuthorizationUrl?: string; + oAuth2ServerAuthorizationUrl?: string | null; /** * OAuth2 server allowed scopes */ - oAuth2ServerScopes?: string[]; + oAuth2ServerScopes?: string[] | null; /** * OAuth2 server scopes used when an authorization request omits the scope parameter */ - oAuth2ServerDefaultScopes?: string[]; + oAuth2ServerDefaultScopes?: string[] | null; /** * Scopes an application may request when installed on a team */ - oAuth2ServerInstallationScopes?: string[]; + oAuth2ServerInstallationScopes?: string[] | null; /** * OAuth2 server accepted RFC 9396 authorization_details types */ - oAuth2ServerAuthorizationDetailsTypes?: string[]; + oAuth2ServerAuthorizationDetailsTypes?: string[] | null; /** * OAuth2 server access token duration in seconds for confidential clients */ - oAuth2ServerAccessTokenDuration?: number; + oAuth2ServerAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for confidential clients */ - oAuth2ServerRefreshTokenDuration?: number; + oAuth2ServerRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicAccessTokenDuration?: number; + oAuth2ServerPublicAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicRefreshTokenDuration?: number; + oAuth2ServerPublicRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for app installation access tokens */ - oAuth2ServerInstallationAccessTokenDuration?: number; + oAuth2ServerInstallationAccessTokenDuration?: number | null; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ - oAuth2ServerConfidentialPkce?: boolean; + oAuth2ServerConfidentialPkce?: boolean | null; /** * URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured. */ - oAuth2ServerVerificationUrl?: string; + oAuth2ServerVerificationUrl?: string | null; /** * Number of characters in the device flow user code, excluding the formatting separator. */ - oAuth2ServerUserCodeLength?: number; + oAuth2ServerUserCodeLength?: number | null; /** * Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`. */ - oAuth2ServerUserCodeFormat?: string; + oAuth2ServerUserCodeFormat?: string | null; /** * Lifetime in seconds of device flow device codes and user codes. */ - oAuth2ServerDeviceCodeDuration?: number; + oAuth2ServerDeviceCodeDuration?: number | null; /** * OAuth2 server discovery URL */ - oAuth2ServerDiscoveryUrl?: string; + oAuth2ServerDiscoveryUrl?: string | null; }; /** @@ -5898,7 +5914,7 @@ export namespace Models { /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ - maxAge?: number; + maxAge?: number | null; }; /** @@ -6251,6 +6267,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6415,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6577,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6822,7 +6878,7 @@ export namespace Models { /** * Type of deployment resource: function, site, or dedicatedDatabase. */ - deploymentResourceType?: ProxyRuleDeploymentResourceType; + deploymentResourceType?: ProxyRuleDeploymentResourceType | null; /** * ID of deployment's resource (site or function ID). Used if type is "deployment" */ @@ -6843,6 +6899,10 @@ export namespace Models { * Certificate auto-renewal date in ISO 8601 format. */ renewAt: string; + /** + * Ingress protocol for the rule. + */ + protocol: ProxyRuleProtocol; }; /** @@ -6931,6 +6991,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -7058,15 +7214,15 @@ export namespace Models { /** * The scheduled time for message. */ - scheduledAt?: string; + scheduledAt?: string | null; /** * The time when the message was delivered. */ - deliveredAt?: string; + deliveredAt?: string | null; /** * Delivery errors if any. */ - deliveryErrors?: string[]; + deliveryErrors?: string[] | null; /** * Number of recipients the message was delivered to. */ @@ -7120,11 +7276,11 @@ export namespace Models { /** * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. */ - qos?: number; + qos?: number | null; /** - * Message retention in seconds for offline delivery. + * Message retention in seconds for offline delivery. Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. */ - expiry?: number; + expiry?: number | null; }; /** @@ -7226,7 +7382,7 @@ export namespace Models { /** * Provider ID. */ - providerId?: string; + providerId?: string | null; /** * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ @@ -7304,15 +7460,15 @@ export namespace Models { /** * Time the insight was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; /** * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - dismissedAt?: string; + dismissedAt?: string | null; /** * User ID that dismissed the insight. Empty when not dismissed. */ - dismissedBy?: string; + dismissedBy?: string | null; }; /** @@ -7388,7 +7544,7 @@ export namespace Models { /** * Time the report was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; }; /** @@ -7566,7 +7722,7 @@ export namespace Models { /** * Archive size in bytes. Null until the size is known. */ - size?: number; + size?: number | null; /** * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ @@ -7574,7 +7730,7 @@ export namespace Models { /** * The backup start time. Null until the backup starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -7590,11 +7746,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this archive should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this archive should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; }; /** @@ -7648,23 +7804,23 @@ export namespace Models { /** * Backup start time in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Backup completion time in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Backup verification time in ISO 8601 format. */ - verifiedAt?: string; + verifiedAt?: string | null; /** * Backup expiration time in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * 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; + logPosition?: string | null; /** * Error message if backup failed. */ @@ -7718,35 +7874,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth?: number; + bandwidth?: number | null; /** * Storage limit */ - storage?: number; + storage?: number | null; /** * Users limit */ - users?: number; + users?: number | null; /** * Executions limit */ - executions?: number; + executions?: number | null; /** * GBHours limit */ - GBHours?: number; + GBHours?: number | null; /** * Image transformations limit */ - imageTransformations?: number; + imageTransformations?: number | null; /** * Auth phone limit */ - authPhone?: number; + authPhone?: number | null; /** * Budget limit percentage */ - budgetLimit?: number; + budgetLimit?: number | null; }; /** @@ -7796,7 +7952,7 @@ export namespace Models { /** * Members */ - members?: number; + members?: number | null; /** * Webhooks */ @@ -7805,6 +7961,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments: number; /** * Projects */ @@ -7892,7 +8052,7 @@ export namespace Models { /** * Activity log days */ - activityLogs?: number; + activityLogs?: number | null; /** * Usage history days */ @@ -7900,11 +8060,11 @@ export namespace Models { /** * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ - usageLogsIntervals?: string[]; + usageLogsIntervals?: string[] | null; /** * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. */ - usageAggregateOnlyMetrics?: string[]; + usageAggregateOnlyMetrics?: string[] | null; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -7916,7 +8076,7 @@ export namespace Models { /** * Additional resources. Null when the plan does not support usage billing. */ - usage?: UsageBillingPlan; + usage?: UsageBillingPlan | null; /** * Addons */ @@ -7944,7 +8104,7 @@ export namespace Models { /** * ISO country codes eligible for this regional plan. Empty means no restriction. */ - eligibleCountries?: string[]; + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8000,7 +8160,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled?: boolean; + backupsEnabled?: boolean | null; /** * Whether usage addons are calculated per project. */ @@ -8012,7 +8172,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies?: number; + backupPolicies?: number | null; /** * Maximum function and site deployment size in MB */ @@ -8021,6 +8181,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8028,7 +8192,7 @@ export namespace Models { /** * Plan specific limits */ - limits?: BillingPlanLimits; + limits?: BillingPlanLimits | null; /** * Group of this billing plan for variants */ @@ -8036,7 +8200,7 @@ export namespace Models { /** * Details of the program this plan is a part of. */ - program?: Program; + program?: Program | null; /** * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. */ @@ -8044,7 +8208,7 @@ export namespace Models { /** * Dedicated database limits available to this plan. */ - dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; + dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits | null; }; /** @@ -8054,11 +8218,11 @@ export namespace Models { /** * Addon seats */ - seats?: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails | null; /** * Addon projects */ - projects?: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails | null; }; /** @@ -8084,7 +8248,7 @@ export namespace Models { /** * Price currency */ - currency?: string; + currency?: string | null; /** * Price */ @@ -8106,11 +8270,11 @@ export namespace Models { /** * Credits limit per billing cycle */ - credits?: number; + credits?: number | null; /** * Daily credits limit (if applicable) */ - dailyCredits?: number; + dailyCredits?: number | null; }; /** @@ -8120,79 +8284,79 @@ export namespace Models { /** * Minimum CPU allocation in millicores. */ - minCpu?: number; + minCpu?: number | null; /** * Maximum CPU allocation in millicores. */ - maxCpu?: number; + maxCpu?: number | null; /** * Minimum memory allocation in megabytes. */ - minMemoryMb?: number; + minMemoryMb?: number | null; /** * Maximum memory allocation in megabytes. */ - maxMemoryMb?: number; + maxMemoryMb?: number | null; /** * Minimum storage allocation in gigabytes. */ - minStorageGb?: number; + minStorageGb?: number | null; /** * Maximum storage allocation in gigabytes. */ - maxStorageGb?: number; + maxStorageGb?: number | null; /** * Maximum number of high-availability replicas per dedicated database. */ - maxReplicas?: number; + maxReplicas?: number | null; /** * Maximum number of client connections. */ - maxConnections?: number; + maxConnections?: number | null; /** * Maximum number of entries allowed in the IP allowlist. */ - maxIpAllowlistSize?: number; + maxIpAllowlistSize?: number | null; /** * Maximum number of database extensions that can be enabled. */ - maxExtensions?: number; + maxExtensions?: number | null; /** * Maximum number of days a backup can be retained. */ - maxBackupRetentionDays?: number; + maxBackupRetentionDays?: number | null; /** * Maximum number of days of point-in-time recovery data that can be retained. */ - maxPitrRetentionDays?: number; + maxPitrRetentionDays?: number | null; /** * Maximum number of rows a single SQL API query can return. */ - maxSqlApiMaxRows?: number; + maxSqlApiMaxRows?: number | null; /** * Maximum response size in bytes for a single SQL API query. */ - maxSqlApiMaxBytes?: number; + maxSqlApiMaxBytes?: number | null; /** * Maximum execution time in seconds for a single SQL API query. */ - maxSqlApiTimeoutSeconds?: number; + maxSqlApiTimeoutSeconds?: number | null; /** * Maximum number of SQL statement types that can be permitted through the SQL API. */ - maxSqlApiAllowedStatements?: number; + maxSqlApiAllowedStatements?: number | null; /** * SQL statement types permitted through the SQL API. */ - allowedSqlStatements?: string[]; + allowedSqlStatements?: string[] | null; /** * Storage classes available for dedicated databases. */ - allowedStorageClasses?: string[]; + allowedStorageClasses?: string[] | null; /** * Replica synchronization modes available for dedicated databases. */ - allowedSyncModes?: string[]; + allowedSyncModes?: string[] | null; }; /** @@ -8236,7 +8400,7 @@ export namespace Models { /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - expiredAt?: string; + expiredAt?: string | null; }; /** @@ -8266,7 +8430,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number | null; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8572,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string | null; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string | null; /** * Database engine version. */ @@ -8432,7 +8596,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number | null; /** * Database username for connections. */ @@ -8444,7 +8608,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number | null; /** * Full database connection string (URI format). */ @@ -8464,11 +8628,11 @@ export namespace Models { /** * Last activity timestamp in ISO 8601 format. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; /** * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. */ - idleUntil?: string; + idleUntil?: string | null; /** * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. */ @@ -8500,7 +8664,7 @@ export namespace Models { /** * Time the in-flight storage resize started, in ISO 8601 format. */ - storageResizeStartedAt?: string; + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8658,7 +8822,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string | null; /** * Project ID. */ @@ -8666,11 +8830,15 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string | null; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ type: string; + /** + * Where the backup was restored. Possible values: in_place (replayed over the database that took the backup), clone (recovered onto a second workload beside the database, which keeps serving until the clone is promoted onto its endpoint), copy (recovered onto a separate database with its own endpoint). + */ + restoreMode: string; /** * Restoration status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). */ @@ -8678,15 +8846,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string | null; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string | null; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string | null; /** * Error message if restoration failed. */ @@ -8720,7 +8888,7 @@ export namespace Models { /** * Connection statistics. Null when the database has not been probed. */ - connections?: DatabaseStatusConnections; + connections?: DatabaseStatusConnections | null; /** * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. */ @@ -8728,7 +8896,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -8744,7 +8912,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -8856,7 +9024,7 @@ export namespace Models { /** * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus?: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum | null; /** * Team ID. */ @@ -8886,7 +9054,7 @@ export namespace Models { /** * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price?: number; + price?: number | null; /** * Price period in years. */ @@ -8898,7 +9066,7 @@ export namespace Models { /** * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. */ - renewalPrice?: number; + renewalPrice?: number | null; /** * Renewal price period in years. */ @@ -8960,11 +9128,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -8998,15 +9166,15 @@ export namespace Models { /** * Time the operation was requested, in ISO 8601 format. */ - requestedAt?: string; + requestedAt?: string | null; /** * Time the operation started, in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Time the operation reached a terminal state, in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ @@ -9046,7 +9214,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -9062,7 +9230,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * Per-pod statuses for the primary and every replica. */ @@ -9124,7 +9292,7 @@ export namespace Models { /** * Project budget limit. Null when no budget is set. */ - billingBudget?: number; + billingBudget?: number | null; /** * Project budget limit */ @@ -9148,43 +9316,43 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string | null; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string | null; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string | null; /** * Start date of trial. */ - billingTrialStartDate?: string; + billingTrialStartDate?: string | null; /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number | null; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string | null; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string | null; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string | null; /** * Default payment method. */ - billingAddressId?: string; + billingAddressId?: string | null; /** * Backup payment method. */ - backupPaymentMethodId?: string; + backupPaymentMethodId?: string | null; /** * Team status. */ @@ -9192,39 +9360,39 @@ export namespace Models { /** * Remarks on team status. */ - remarks?: string; + remarks?: string | null; /** * Organization agreements */ - agreementBAA?: string; + agreementBAA?: string | null; /** * Program manager's name. */ - programManagerName?: string; + programManagerName?: string | null; /** * Program manager's calendar link. */ - programManagerCalendar?: string; + programManagerCalendar?: string | null; /** * Program's discord channel name. */ - programDiscordChannelName?: string; + programDiscordChannelName?: string | null; /** * Program's discord channel URL. */ - programDiscordChannelUrl?: string; + programDiscordChannelUrl?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * Billing plan selected for downgrade. */ - billingPlanDowngrade?: string; + billingPlanDowngrade?: string | null; /** * Tax Id */ - billingTaxId?: string; + billingTaxId?: string | null; /** * Marked for deletion */ @@ -9284,11 +9452,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this policy should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this policy should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; /** * How many days to keep the backup before it will be automatically deleted. */ @@ -9448,7 +9616,7 @@ export namespace Models { /** * The restoration start time. Null until the restoration starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -9586,11 +9754,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -9622,47 +9790,47 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource | null; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource | null; /** * Member additional resources */ - member?: AdditionalResource; + member?: AdditionalResource | null; /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource | null; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource | null; /** * Realtime bandwidth additional resources */ - realtimeBandwidth?: AdditionalResource; + realtimeBandwidth?: AdditionalResource | null; /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource | null; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource | null; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource | null; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource | null; /** * Credits additional resources */ - credits?: AdditionalResource; + credits?: AdditionalResource | null; }; /** @@ -9814,7 +9982,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9856,7 +10024,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9928,7 +10096,7 @@ export namespace Models { /** * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9970,7 +10138,7 @@ export namespace Models { /** * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -10132,11 +10300,11 @@ export namespace Models { /** * Granted RFC 9396 authorization details as a JSON string. */ - authorization_details?: string; + authorization_details?: string | null; /** * OpenID Connect ID token. Returned when the `openid` scope is granted. */ - id_token?: string; + id_token?: string | null; }; /** @@ -10150,47 +10318,47 @@ export namespace Models { /** * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. */ - token_use?: string; + token_use?: string | null; /** * OAuth2 token type. */ - token_type?: string; + token_type?: string | null; /** * Space-separated scopes granted to the token. */ - scope?: string; + scope?: string | null; /** * OAuth2 client ID the token was issued to. */ - client_id?: string; + client_id?: string | null; /** * ID of the user who authorized the token. */ - sub?: string; + sub?: string | null; /** * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). */ - aud?: string[]; + aud?: string[] | null; /** * Issuer URL of the token. */ - iss?: string; + iss?: string | null; /** * Expiration time as a Unix timestamp in seconds. */ - exp?: number; + exp?: number | null; /** * Issued-at time as a Unix timestamp in seconds. */ - iat?: number; + iat?: number | null; /** * Unique identifier of the token. */ - jti?: string; + jti?: string | null; /** * Granted RFC 9396 authorization details, restricted to what the user can currently access. */ - authorization_details?: Record<string, any>[]; + authorization_details?: Record<string, any>[] | null; }; /** @@ -10289,6 +10457,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/query.ts b/src/query.ts index 7a7da88..ca0b350 100644 --- a/src/query.ts +++ b/src/query.ts @@ -468,6 +468,20 @@ export class Query { queries.map((query) => JSONbig.parse(query)), ).toString(); + /** + * Constrain populated related documents on a relationship attribute. + * + * @param {string} attribute The relationship attribute to query. + * @param {string[]} queries Filter, order, select, and pagination queries applied to related documents. + * @returns {string} + */ + static relationship = (attribute: string, queries: string[]): string => + new Query( + 'relationship', + attribute, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + /** * Filter resources where attribute is at a specific distance from the given coordinates. * @@ -659,4 +673,799 @@ export class Query { */ static notTouches = (attribute: string, values: any[]): string => new Query('notTouches', attribute, [values]).toString(); + + /** + * Count documents, optionally aliased. + */ + static count = (attribute: string = '*', alias: string = ''): string => + new Query( + 'count', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Count distinct values of attribute, optionally aliased. + */ + static countDistinct = (attribute: string, alias: string = ''): string => + new Query( + 'countDistinct', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sum values of `attribute`, optionally aliased. */ + static sum = (attribute: string, alias: string = ''): string => + new Query( + 'sum', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Average values of `attribute`, optionally aliased. */ + static avg = (attribute: string, alias: string = ''): string => + new Query( + 'avg', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Minimum value of `attribute`, optionally aliased. */ + static min = (attribute: string, alias: string = ''): string => + new Query( + 'min', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Maximum value of `attribute`, optionally aliased. */ + static max = (attribute: string, alias: string = ''): string => + new Query( + 'max', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Standard deviation of `attribute`, optionally aliased. */ + static stddev = (attribute: string, alias: string = ''): string => + new Query( + 'stddev', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population standard deviation of `attribute`, optionally aliased. */ + static stddevPop = (attribute: string, alias: string = ''): string => + new Query( + 'stddevPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample standard deviation of `attribute`, optionally aliased. */ + static stddevSamp = (attribute: string, alias: string = ''): string => + new Query( + 'stddevSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Variance of `attribute`, optionally aliased. */ + static variance = (attribute: string, alias: string = ''): string => + new Query( + 'variance', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population variance of `attribute`, optionally aliased. */ + static varPop = (attribute: string, alias: string = ''): string => + new Query( + 'varPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample variance of `attribute`, optionally aliased. */ + static varSamp = (attribute: string, alias: string = ''): string => + new Query( + 'varSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise AND of `attribute`, optionally aliased. */ + static bitAnd = (attribute: string, alias: string = ''): string => + new Query( + 'bitAnd', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise OR of `attribute`, optionally aliased. */ + static bitOr = (attribute: string, alias: string = ''): string => + new Query( + 'bitOr', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise XOR of `attribute`, optionally aliased. */ + static bitXor = (attribute: string, alias: string = ''): string => + new Query( + 'bitXor', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Group results by attributes. + */ + static groupBy = (attributes: string[]): string => + new Query('groupBy', undefined, attributes).toString(); + + /** + * Filter grouped results. `queries` are nested like `and`/`or`. + */ + static having = (queries: string[]): string => + new Query( + 'having', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** Select distinct rows. */ + static distinct = (): string => new Query('distinct').toString(); + + /** + * Column-to-column join ON condition. + */ + static on = (left: string, right: string, operator: string = '='): string => + new Query('on', undefined, [left, operator, right]).toString(); + + /** + * Inner join. `table` is the joined collection/table ID. + */ + static join = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'join', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Left join. `table` is the joined collection/table ID. */ + static leftJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'leftJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Right join. `table` is the joined collection/table ID. */ + static rightJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'rightJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Full outer join. `table` is the joined collection/table ID. */ + static fullOuterJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'fullOuterJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Cross join. `table` is the joined collection/table ID. */ + static crossJoin = (table: string, alias: string = ''): string => + new Query( + 'crossJoin', + table, + alias !== '' ? alias : undefined, + ).toString(); + + /** Filter resources where `attribute` covers the given geometry. */ + static covers = (attribute: string, values: any[]): string => + new Query('covers', attribute, [values]).toString(); + + /** Filter resources where `attribute` does not cover the given geometry. */ + static notCovers = (attribute: string, values: any[]): string => + new Query('notCovers', attribute, [values]).toString(); + + /** Filter resources where `attribute` is spatially equal to the given geometry. */ + static spatialEquals = (attribute: string, values: any[]): string => + new Query('spatialEquals', attribute, [values]).toString(); + + /** Filter resources where `attribute` is not spatially equal to the given geometry. */ + static notSpatialEquals = (attribute: string, values: any[]): string => + new Query('notSpatialEquals', attribute, [values]).toString(); + + /** + * Return limit and offset queries for 1-based page pagination. + */ + static page = (page: number, perPage: number = 25): string[] => { + if (page < 1) { + throw new Error('Page must be >= 1, got ' + page); + } + if (perPage < 1) { + throw new Error('Per page must be >= 1, got ' + perPage); + } + return [Query.limit(perPage), Query.offset((page - 1) * perPage)]; + }; + + /** Start a fluent query builder. */ + static builder = (): Query.Builder => new Query.Builder(); + + private static createJoin( + method: string, + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string { + if (Array.isArray(leftOrAliasOrOn)) { + return Query.nestedJoin(method, table, '', leftOrAliasOrOn); + } + if (Array.isArray(rightOrOn)) { + return Query.nestedJoin(method, table, leftOrAliasOrOn, rightOrOn); + } + return new Query( + method, + table, + alias !== '' + ? [leftOrAliasOrOn, operator, rightOrOn, alias] + : [leftOrAliasOrOn, operator, rightOrOn], + ).toString(); + } + + private static nestedJoin( + method: string, + table: string, + alias: string, + on: string[], + ): string { + const values: any[] = []; + if (alias !== '') { + values.push(alias); + } + for (const query of on) { + values.push(JSONbig.parse(query)); + } + return new Query(method, table, values).toString(); + } +} + +export type QueryInput = string | Query | Query.Builder | QueryInput[]; + +/** + * Fluent collector of Query fragments. Call {@link Query.Builder.build} to + * produce the `string[]` expected by list/createQuery methods. + */ +export namespace Query { + export class Builder { + private readonly queries: string[] = []; + + build(): string[] { + return [...this.queries]; + } + + equal(attribute: string, value: QueryTypes): this { + return this.push(Query.equal(attribute, value)); + } + + notEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.notEqual(attribute, value)); + } + + lessThan(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThan(attribute, value)); + } + + lessThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThanEqual(attribute, value)); + } + + greaterThan(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThan(attribute, value)); + } + + greaterThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThanEqual(attribute, value)); + } + + search(attribute: string, value: string): this { + return this.push(Query.search(attribute, value)); + } + + isNull(attribute: string): this { + return this.push(Query.isNull(attribute)); + } + + isNotNull(attribute: string): this { + return this.push(Query.isNotNull(attribute)); + } + + between( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.between(attribute, start, end)); + } + + startsWith(attribute: string, value: string): this { + return this.push(Query.startsWith(attribute, value)); + } + + endsWith(attribute: string, value: string): this { + return this.push(Query.endsWith(attribute, value)); + } + + select(attributes: string[]): this { + return this.push(Query.select(attributes)); + } + + cursorAfter(documentId: string): this { + return this.push(Query.cursorAfter(documentId)); + } + + cursorBefore(documentId: string): this { + return this.push(Query.cursorBefore(documentId)); + } + + orderAsc(attribute: string): this { + return this.push(Query.orderAsc(attribute)); + } + + orderDesc(attribute: string): this { + return this.push(Query.orderDesc(attribute)); + } + + orderRandom(): this { + return this.push(Query.orderRandom()); + } + + limit(limit: number): this { + return this.push(Query.limit(limit)); + } + + offset(offset: number): this { + return this.push(Query.offset(offset)); + } + + contains(attribute: string, value: string | any[]): this { + return this.push(Query.contains(attribute, value)); + } + + containsAny(attribute: string, value: any[]): this { + return this.push(Query.containsAny(attribute, value)); + } + + containsAll(attribute: string, value: any[]): this { + return this.push(Query.containsAll(attribute, value)); + } + + notContains(attribute: string, value: string | any[]): this { + return this.push(Query.notContains(attribute, value)); + } + + notSearch(attribute: string, value: string): this { + return this.push(Query.notSearch(attribute, value)); + } + + notBetween( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.notBetween(attribute, start, end)); + } + + notStartsWith(attribute: string, value: string): this { + return this.push(Query.notStartsWith(attribute, value)); + } + + notEndsWith(attribute: string, value: string): this { + return this.push(Query.notEndsWith(attribute, value)); + } + + regex(attribute: string, pattern: string): this { + return this.push(Query.regex(attribute, pattern)); + } + + exists(attributes: string[]): this { + return this.push(Query.exists(attributes)); + } + + notExists(attributes: string[]): this { + return this.push(Query.notExists(attributes)); + } + + createdBefore(value: string): this { + return this.push(Query.createdBefore(value)); + } + + createdAfter(value: string): this { + return this.push(Query.createdAfter(value)); + } + + createdBetween(start: string, end: string): this { + return this.push(Query.createdBetween(start, end)); + } + + updatedBefore(value: string): this { + return this.push(Query.updatedBefore(value)); + } + + updatedAfter(value: string): this { + return this.push(Query.updatedAfter(value)); + } + + updatedBetween(start: string, end: string): this { + return this.push(Query.updatedBetween(start, end)); + } + + or(queries: string[]): this { + return this.push(Query.or(queries)); + } + + and(queries: string[]): this { + return this.push(Query.and(queries)); + } + + elemMatch(attribute: string, queries: string[]): this { + return this.push(Query.elemMatch(attribute, queries)); + } + + relationship(attribute: string, queries: string[]): this { + return this.push(Query.relationship(attribute, queries)); + } + + distanceEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceEqual(attribute, values, distance, meters), + ); + } + + distanceNotEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceNotEqual(attribute, values, distance, meters), + ); + } + + distanceGreaterThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceGreaterThan(attribute, values, distance, meters), + ); + } + + distanceLessThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceLessThan(attribute, values, distance, meters), + ); + } + + intersects(attribute: string, values: any[]): this { + return this.push(Query.intersects(attribute, values)); + } + + notIntersects(attribute: string, values: any[]): this { + return this.push(Query.notIntersects(attribute, values)); + } + + crosses(attribute: string, values: any[]): this { + return this.push(Query.crosses(attribute, values)); + } + + notCrosses(attribute: string, values: any[]): this { + return this.push(Query.notCrosses(attribute, values)); + } + + overlaps(attribute: string, values: any[]): this { + return this.push(Query.overlaps(attribute, values)); + } + + notOverlaps(attribute: string, values: any[]): this { + return this.push(Query.notOverlaps(attribute, values)); + } + + touches(attribute: string, values: any[]): this { + return this.push(Query.touches(attribute, values)); + } + + notTouches(attribute: string, values: any[]): this { + return this.push(Query.notTouches(attribute, values)); + } + + count(attribute: string = '*', alias: string = ''): this { + return this.push(Query.count(attribute, alias)); + } + + countDistinct(attribute: string, alias: string = ''): this { + return this.push(Query.countDistinct(attribute, alias)); + } + + sum(attribute: string, alias: string = ''): this { + return this.push(Query.sum(attribute, alias)); + } + + avg(attribute: string, alias: string = ''): this { + return this.push(Query.avg(attribute, alias)); + } + + min(attribute: string, alias: string = ''): this { + return this.push(Query.min(attribute, alias)); + } + + max(attribute: string, alias: string = ''): this { + return this.push(Query.max(attribute, alias)); + } + + stddev(attribute: string, alias: string = ''): this { + return this.push(Query.stddev(attribute, alias)); + } + + stddevPop(attribute: string, alias: string = ''): this { + return this.push(Query.stddevPop(attribute, alias)); + } + + stddevSamp(attribute: string, alias: string = ''): this { + return this.push(Query.stddevSamp(attribute, alias)); + } + + variance(attribute: string, alias: string = ''): this { + return this.push(Query.variance(attribute, alias)); + } + + varPop(attribute: string, alias: string = ''): this { + return this.push(Query.varPop(attribute, alias)); + } + + varSamp(attribute: string, alias: string = ''): this { + return this.push(Query.varSamp(attribute, alias)); + } + + bitAnd(attribute: string, alias: string = ''): this { + return this.push(Query.bitAnd(attribute, alias)); + } + + bitOr(attribute: string, alias: string = ''): this { + return this.push(Query.bitOr(attribute, alias)); + } + + bitXor(attribute: string, alias: string = ''): this { + return this.push(Query.bitXor(attribute, alias)); + } + + groupBy(attributes: string[]): this { + return this.push(Query.groupBy(attributes)); + } + + having(queries: string[]): this { + return this.push(Query.having(queries)); + } + + distinct(): this { + return this.push(Query.distinct()); + } + + join( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.join(table, leftOrAliasOrOn, rightOrOn, operator, alias), + ); + } + + leftJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.leftJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + rightJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.rightJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + fullOuterJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.fullOuterJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + crossJoin(table: string, alias: string = ''): this { + return this.push(Query.crossJoin(table, alias)); + } + + vectorDot(attribute: string, vector: number[]): this { + return this.push(Query.vectorDot(attribute, vector)); + } + + vectorCosine(attribute: string, vector: number[]): this { + return this.push(Query.vectorCosine(attribute, vector)); + } + + vectorEuclidean(attribute: string, vector: number[]): this { + return this.push(Query.vectorEuclidean(attribute, vector)); + } + + covers(attribute: string, values: any[]): this { + return this.push(Query.covers(attribute, values)); + } + + notCovers(attribute: string, values: any[]): this { + return this.push(Query.notCovers(attribute, values)); + } + + spatialEquals(attribute: string, values: any[]): this { + return this.push(Query.spatialEquals(attribute, values)); + } + + notSpatialEquals(attribute: string, values: any[]): this { + return this.push(Query.notSpatialEquals(attribute, values)); + } + + page(page: number, perPage: number = 25): this { + return this.push(Query.page(page, perPage)); + } + + private push(query: string | string[]): this { + if (Array.isArray(query)) { + this.queries.push(...query); + } else { + this.queries.push(query); + } + return this; + } + } +} + +export function normalizeQueries(queries?: QueryInput | null): string[] { + if (queries == null) { + return []; + } + if (queries instanceof Query.Builder) { + return queries.build(); + } + if (!Array.isArray(queries)) { + if (queries instanceof Query) { + return [queries.toString()]; + } + if (typeof queries === 'string') { + return [queries]; + } + return []; + } + + const out: string[] = []; + for (const item of queries) { + out.push(...normalizeQueries(item)); + } + return out; } + +function isQueryValue(value: unknown): value is Query | Query.Builder { + return value instanceof Query.Builder || value instanceof Query; +} + +export function flattenParam(value: unknown): unknown { + if (isQueryValue(value)) { + return normalizeQueries(value); + } + if (!Array.isArray(value)) { + return value; + } + + const out: unknown[] = []; + for (const item of value) { + if (isQueryValue(item)) { + out.push(...normalizeQueries(item)); + } else { + out.push(flattenParam(item)); + } + } + return out; +} + +export const QueryBuilder = Query.Builder; +export type QueryBuilder = Query.Builder; diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..8c05720 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +186,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +297,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + consents: [], + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +542,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +648,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +824,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +935,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1084,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1185,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1348,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1470,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1684,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1850,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1966,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2026,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2061,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2097,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2128,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2161,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2193,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2226,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2258,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2330,538 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.PasskeyList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise<Models.PasskeyChallenge>; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise<Models.PasskeyChallenge>; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise<Models.PasskeyChallenge> { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { passkeyId: string }): Promise<Models.Passkey>; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise<Models.Passkey> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise<Models.Passkey>; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise<Models.Passkey>; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2940,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3062,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3189,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3300,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3411,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3502,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3611,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3679,58 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3802,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2389,14 +3852,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. - * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ createEmailPasswordSession(params: { email: string; password: string; - duration?: number; + duration?: number | null; }): Promise<Models.Session>; /** * 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. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. @@ -2405,7 +3868,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. - * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2413,14 +3876,19 @@ export class Account { createEmailPasswordSession( email: string, password: string, - duration?: number, + duration?: number | null, ): Promise<Models.Session>; createEmailPasswordSession( paramsOrFirst: - { email: string; password: string; duration?: number } | string, - ...rest: [string?, number?] + | { email: string; password: string; duration?: number | null } + | string, + ...rest: [string?, (number | null)?] ): Promise<Models.Session> { - let params: { email: string; password: string; duration?: number }; + let params: { + email: string; + password: string; + duration?: number | null; + }; if ( paramsOrFirst && @@ -2430,13 +3898,13 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; - duration?: number; + duration?: number | null; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, - duration: rest[1] as number, + duration: rest[1] as number | null, }; } @@ -2470,7 +3938,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4140,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4255,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4367,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4478,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4573,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4669,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4785,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4919,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5043,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5076,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} */ @@ -3259,6 +5085,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise<string>; /** * 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. @@ -3273,6 +5100,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5110,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise<string>; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5119,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise<string> { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5139,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5155,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5163,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5183,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5196,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskeyToken(): Promise<Models.PasskeyChallenge> { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise<Models.TokenSecret>; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise<Models.TokenSecret>; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.TokenSecret> { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5396,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5473,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5551,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5642,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5731,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5808,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5901,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5938,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6029,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..d082ca4 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,58 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + events: [], + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +171,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..b19ab4f 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,76 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + reports: [], + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +206,65 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +405,56 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +526,44 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..ff362ed 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,72 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + apps: [], + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +450,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +523,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +569,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +647,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1019,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1206,38 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1311,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1478,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1575,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1659,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1738,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1889,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2024,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2108,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2195,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2345,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..d8dfb94 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,41 +64,71 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + archives: [], + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} params.services - Array of services to backup - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} */ createArchive(params: { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }): Promise<Models.BackupArchive>; /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} services - Array of services to backup - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} * @deprecated Use the object parameter style method for a better developer experience. */ createArchive( services: BackupServices[], - resourceId?: string, + resourceId?: string | null, ): Promise<Models.BackupArchive>; createArchive( paramsOrFirst: - | { services: BackupServices[]; resourceId?: string } + | { services: BackupServices[]; resourceId?: string | null } | BackupServices[], - ...rest: [string?] + ...rest: [(string | null)?] ): Promise<Models.BackupArchive> { - let params: { services: BackupServices[]; resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string | null }; if ( paramsOrFirst && @@ -103,12 +138,12 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string, + resourceId: rest[0] as string | null, }; } @@ -135,7 +170,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +244,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +370,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +413,7 @@ export class Backups { * @param {number} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Schedule CRON syntax. * @param {string} params.name - Policy name. Max length: 128 chars. - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -319,7 +424,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }): Promise<Models.BackupPolicy>; /** @@ -330,7 +435,7 @@ export class Backups { * @param {number} retention - Days to keep backups before deletion * @param {string} schedule - Schedule CRON syntax. * @param {string} name - Policy name. Max length: 128 chars. - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -342,7 +447,7 @@ export class Backups { retention: number, schedule: string, name?: string, - resourceId?: string, + resourceId?: string | null, enabled?: boolean, ): Promise<Models.BackupPolicy>; createPolicy( @@ -353,7 +458,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; } | string, @@ -362,7 +467,7 @@ export class Backups { number?, string?, string?, - string?, + (string | null)?, boolean?, ] ): Promise<Models.BackupPolicy> { @@ -372,7 +477,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; @@ -387,7 +492,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; } else { @@ -397,7 +502,7 @@ export class Backups { retention: rest[1] as number, schedule: rest[2] as string, name: rest[3] as string, - resourceId: rest[4] as string, + resourceId: rest[4] as string | null, enabled: rest[5] as boolean, }; } @@ -460,7 +565,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,64 +641,90 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update an existing policy using it's ID. * * @param {string} params.policyId - Policy ID. Choose a custom ID`. 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 {number} params.retention - Days to keep backups before deletion + * @param {string | null} params.name - Policy name. Max length: 128 chars. + * @param {number | null} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Cron expression - * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updatePolicy(params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * Update an existing policy using it's ID. * * @param {string} policyId - Policy ID. Choose a custom ID`. 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 {number} retention - Days to keep backups before deletion + * @param {string | null} name - Policy name. Max length: 128 chars. + * @param {number | null} retention - Days to keep backups before deletion * @param {string} schedule - Cron expression - * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePolicy( policyId: string, - name?: string, - retention?: number, + name?: string | null, + retention?: number | null, schedule?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updatePolicy( paramsOrFirst: | { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, number?, string?, boolean?] + ...rest: [ + (string | null)?, + (number | null)?, + string?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -582,18 +734,18 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { policyId: paramsOrFirst as string, - name: rest[0] as string, - retention: rest[1] as number, + name: rest[0] as string | null, + retention: rest[1] as number | null, schedule: rest[2] as string, - enabled: rest[3] as boolean, + enabled: rest[3] as boolean | null, }; } @@ -632,7 +784,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +987,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1061,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1150,27 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..0b2d328 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,69 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +246,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +366,35 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +447,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +522,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +629,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +779,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +852,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +988,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1199,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -892,11 +1259,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. @@ -905,7 +1272,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -917,11 +1284,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,7 +1297,7 @@ export class Databases { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -942,7 +1309,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -952,7 +1319,7 @@ export class Databases { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -963,7 +1330,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -979,7 +1346,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -990,7 +1357,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1053,7 +1420,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1537,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1139,7 +1586,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1151,7 +1598,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1162,7 +1609,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1174,7 +1621,7 @@ export class Databases { databaseId: string, collectionId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1185,19 +1632,26 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Collection> { let params: { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1212,7 +1666,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1222,7 +1676,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -1276,7 +1730,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1955,20 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + attributes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1472,9 +1979,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1485,9 +1992,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeBigint>; /** @@ -1498,9 +2005,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1511,9 +2018,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeBigint>; createBigIntAttribute( @@ -1523,9 +2030,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -1533,9 +2040,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeBigint> { @@ -1544,9 +2051,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -1560,9 +2067,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -1571,9 +2078,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -1638,7 +2145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,10 +2173,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. @@ -1662,10 +2186,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeBigint>; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. @@ -1675,10 +2199,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1688,10 +2212,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeBigint>; updateBigIntAttribute( paramsOrFirst: @@ -1700,20 +2224,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeBigint> { let params: { @@ -1721,10 +2245,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -1737,10 +2261,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -1748,10 +2272,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -1818,7 +2342,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1829,7 +2370,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1840,7 +2381,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.AttributeBoolean>; /** @@ -1851,7 +2392,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1862,7 +2403,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.AttributeBoolean>; createBooleanAttribute( @@ -1872,18 +2413,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -1897,7 +2438,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -1906,7 +2447,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -1963,7 +2504,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1973,8 +2531,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. @@ -1984,8 +2542,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.AttributeBoolean>; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -1994,8 +2552,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2005,8 +2563,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.AttributeBoolean>; updateBooleanAttribute( paramsOrFirst: @@ -2015,19 +2573,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2040,8 +2604,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2049,8 +2613,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2109,7 +2673,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2119,7 +2700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2130,7 +2711,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeDatetime>; /** @@ -2140,7 +2721,7 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2151,7 +2732,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeDatetime>; createDatetimeAttribute( @@ -2161,18 +2742,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2186,7 +2767,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2195,7 +2776,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2252,7 +2833,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2262,8 +2860,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. @@ -2273,8 +2871,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeDatetime>; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -2283,8 +2881,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2294,8 +2892,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeDatetime>; updateDatetimeAttribute( paramsOrFirst: @@ -2304,19 +2902,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2329,8 +2933,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2338,8 +2942,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2398,7 +3002,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2409,7 +3030,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2420,7 +3041,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEmail>; /** @@ -2431,7 +3052,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2442,7 +3063,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEmail>; createEmailAttribute( @@ -2452,18 +3073,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2477,7 +3098,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2486,7 +3107,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2543,7 +3164,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2554,8 +3193,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. @@ -2565,8 +3204,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEmail>; /** * Update an email attribute. Changing the `default` value will not update already existing documents. @@ -2576,8 +3215,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2587,8 +3226,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEmail>; updateEmailAttribute( paramsOrFirst: @@ -2597,19 +3236,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2622,8 +3267,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2631,8 +3276,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2691,7 +3336,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2703,7 +3366,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2715,7 +3378,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEnum>; /** @@ -2727,7 +3390,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2739,7 +3402,7 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEnum>; createEnumAttribute( @@ -2750,11 +3413,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2762,7 +3432,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2777,7 +3447,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2787,7 +3457,7 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -2853,7 +3523,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2865,8 +3554,8 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. @@ -2877,8 +3566,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEnum>; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -2889,8 +3578,8 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2901,8 +3590,8 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEnum>; updateEnumAttribute( paramsOrFirst: @@ -2912,11 +3601,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2924,8 +3620,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2939,8 +3635,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2949,8 +3645,8 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3018,7 +3714,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3029,9 +3744,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3042,9 +3757,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.AttributeFloat>; /** @@ -3055,9 +3770,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3068,9 +3783,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.AttributeFloat>; createFloatAttribute( @@ -3080,9 +3795,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3090,9 +3805,9 @@ export class Databases { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.AttributeFloat> { @@ -3101,9 +3816,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3117,9 +3832,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3128,9 +3843,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3195,7 +3910,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3206,10 +3938,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {string} params.newKey - New Attribute Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. @@ -3219,10 +3951,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.AttributeFloat>; /** * Update a float attribute. Changing the `default` value will not update already existing documents. @@ -3232,10 +3964,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {string} newKey - New Attribute Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3245,10 +3977,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.AttributeFloat>; updateFloatAttribute( paramsOrFirst: @@ -3257,20 +3989,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.AttributeFloat> { let params: { @@ -3278,10 +4010,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3294,10 +4026,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3305,10 +4037,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -3375,7 +4107,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3386,9 +4135,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3399,9 +4148,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeInteger>; /** @@ -3412,9 +4161,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3425,9 +4174,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeInteger>; createIntegerAttribute( @@ -3437,9 +4186,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -3447,9 +4196,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeInteger> { @@ -3458,9 +4207,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -3474,9 +4223,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -3485,9 +4234,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -3552,7 +4301,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,10 +4329,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. @@ -3576,10 +4342,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeInteger>; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -3589,10 +4355,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3602,10 +4368,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeInteger>; updateIntegerAttribute( paramsOrFirst: @@ -3614,20 +4380,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeInteger> { let params: { @@ -3635,10 +4401,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -3651,10 +4417,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -3662,10 +4428,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -3732,7 +4498,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3743,7 +4526,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3754,7 +4537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeIp>; /** @@ -3765,7 +4548,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3776,7 +4559,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeIp>; createIpAttribute( @@ -3786,18 +4569,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3811,7 +4594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3820,7 +4603,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3877,7 +4660,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3888,8 +4689,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. @@ -3899,8 +4700,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeIp>; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -3910,8 +4711,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3921,8 +4722,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeIp>; updateIpAttribute( paramsOrFirst: @@ -3931,19 +4732,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3956,8 +4763,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3965,8 +4772,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4025,7 +4832,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4035,7 +4860,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. @@ -4045,7 +4870,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributeLine>; /** * Create a geometric line attribute. @@ -4054,7 +4879,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4064,7 +4889,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributeLine>; createLineAttribute( paramsOrFirst: @@ -4073,17 +4898,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4096,7 +4921,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4104,7 +4929,7 @@ export class Databases { 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[][] | null, }; } @@ -4156,7 +4981,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4166,8 +5008,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. @@ -4177,8 +5019,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributeLine>; /** * Update a line attribute. Changing the `default` value will not update already existing documents. @@ -4187,8 +5029,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4198,8 +5040,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributeLine>; updateLineAttribute( paramsOrFirst: @@ -4208,19 +5050,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4233,8 +5081,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4242,8 +5090,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4297,7 +5145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4308,7 +5173,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4320,7 +5185,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeLongtext>; @@ -4332,7 +5197,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4344,7 +5209,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeLongtext>; @@ -4355,19 +5220,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4382,7 +5254,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4392,7 +5264,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4454,7 +5326,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4465,8 +5354,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. @@ -4476,8 +5365,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeLongtext>; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -4487,8 +5376,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4498,8 +5387,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeLongtext>; updateLongtextAttribute( paramsOrFirst: @@ -4508,19 +5397,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4533,8 +5428,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4542,8 +5437,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4602,7 +5497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4613,7 +5525,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4625,7 +5537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeMediumtext>; @@ -4637,7 +5549,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4649,7 +5561,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeMediumtext>; @@ -4660,19 +5572,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4687,7 +5606,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4697,7 +5616,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4759,7 +5678,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4770,8 +5706,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. @@ -4781,8 +5717,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeMediumtext>; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -4792,8 +5728,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4803,8 +5739,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeMediumtext>; updateMediumtextAttribute( paramsOrFirst: @@ -4813,19 +5749,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4838,8 +5780,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4847,8 +5789,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4907,7 +5849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4917,7 +5876,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. @@ -4927,7 +5886,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.AttributePoint>; /** * Create a geometric point attribute. @@ -4936,7 +5895,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4946,7 +5905,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.AttributePoint>; createPointAttribute( paramsOrFirst: @@ -4955,17 +5914,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -4978,7 +5937,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -4986,7 +5945,7 @@ export class Databases { 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[] | null, }; } @@ -5038,7 +5997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5048,8 +6024,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. @@ -5059,8 +6035,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.AttributePoint>; /** * Update a point attribute. Changing the `default` value will not update already existing documents. @@ -5069,8 +6045,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5080,8 +6056,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.AttributePoint>; updatePointAttribute( paramsOrFirst: @@ -5090,19 +6066,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5115,8 +6097,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5124,8 +6106,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5179,7 +6161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5189,7 +6188,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. @@ -5199,7 +6198,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributePolygon>; /** * Create a geometric polygon attribute. @@ -5208,7 +6207,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5218,7 +6217,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributePolygon>; createPolygonAttribute( paramsOrFirst: @@ -5227,17 +6226,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5250,7 +6249,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5258,7 +6257,7 @@ export class Databases { 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[][] | null, }; } @@ -5310,7 +6309,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5320,8 +6336,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. @@ -5331,8 +6347,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributePolygon>; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -5341,8 +6357,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5352,8 +6368,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributePolygon>; updatePolygonAttribute( paramsOrFirst: @@ -5362,19 +6378,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -5387,8 +6409,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -5396,8 +6418,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -5451,7 +6473,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5463,8 +6502,8 @@ export class Databases { * @param {string} params.relatedCollectionId - Related Collection ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Attribute Key. - * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {string | null} params.key - Attribute Key. + * @param {string | null} params.twoWayKey - Two Way Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5476,8 +6515,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.AttributeRelationship>; /** @@ -5489,8 +6528,8 @@ export class Databases { * @param {string} relatedCollectionId - Related Collection ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Attribute Key. - * @param {string} twoWayKey - Two Way Attribute Key. + * @param {string | null} key - Attribute Key. + * @param {string | null} twoWayKey - Two Way Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5502,8 +6541,8 @@ export class Databases { relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.AttributeRelationship>; createRelationshipAttribute( @@ -5514,8 +6553,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -5524,8 +6563,8 @@ export class Databases { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.AttributeRelationship> { @@ -5535,8 +6574,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -5551,8 +6590,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -5562,8 +6601,8 @@ export class Databases { relatedCollectionId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -5628,7 +6667,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5639,7 +6700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. @@ -5649,7 +6710,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }): Promise<Models.AttributeRelationship>; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -5659,7 +6720,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Attribute Key. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5669,7 +6730,7 @@ export class Databases { collectionId: string, key: string, onDelete?: RelationMutate, - newKey?: string, + newKey?: string | null, ): Promise<Models.AttributeRelationship>; updateRelationshipAttribute( paramsOrFirst: @@ -5678,17 +6739,17 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, RelationMutate?, (string | null)?] ): Promise<Models.AttributeRelationship> { let params: { databaseId: string; collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; if ( @@ -5701,7 +6762,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; } else { params = { @@ -5709,7 +6770,7 @@ export class Databases { 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 | null, }; } @@ -5754,7 +6815,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5766,7 +6849,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for text attributes, in number of characters. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5779,7 +6862,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeString>; @@ -5792,7 +6875,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for text attributes, in number of characters. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5805,7 +6888,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeString>; @@ -5817,7 +6900,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -5827,7 +6910,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -5838,7 +6921,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5854,7 +6937,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5865,7 +6948,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -5934,7 +7017,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5945,9 +7046,9 @@ export class Databases { * @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). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the string attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the string attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. @@ -5957,9 +7058,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeString>; /** * Update a string attribute. Changing the `default` value will not update already existing documents. @@ -5969,9 +7070,9 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the string attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the string attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5981,9 +7082,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeString>; updateStringAttribute( paramsOrFirst: @@ -5992,21 +7093,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeString> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6019,9 +7127,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6029,9 +7137,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6094,7 +7202,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6105,7 +7231,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6117,7 +7243,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeText>; @@ -6129,7 +7255,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6141,7 +7267,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeText>; @@ -6152,19 +7278,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6179,7 +7312,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6189,7 +7322,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6251,7 +7384,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6262,8 +7412,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6273,8 +7423,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeText>; /** * Update a text attribute. Changing the `default` value will not update already existing documents. @@ -6284,8 +7434,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6295,8 +7445,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeText>; updateTextAttribute( paramsOrFirst: @@ -6305,19 +7455,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6330,8 +7486,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6339,8 +7495,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6399,7 +7555,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7583,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6421,7 +7594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeUrl>; /** @@ -6432,7 +7605,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6443,7 +7616,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeUrl>; createUrlAttribute( @@ -6453,18 +7626,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -6478,7 +7651,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -6487,7 +7660,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -6544,7 +7717,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6555,8 +7746,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. @@ -6566,8 +7757,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeUrl>; /** * Update an url attribute. Changing the `default` value will not update already existing documents. @@ -6577,8 +7768,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6588,8 +7779,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeUrl>; updateUrlAttribute( paramsOrFirst: @@ -6598,19 +7789,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6623,8 +7820,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6632,8 +7829,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6692,7 +7889,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6704,7 +7919,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6717,7 +7932,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeVarchar>; @@ -6730,7 +7945,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6743,7 +7958,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeVarchar>; @@ -6755,7 +7970,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6765,7 +7980,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6776,7 +7991,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6792,7 +8007,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6803,7 +8018,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6872,7 +8087,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6883,9 +8116,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the varchar attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the varchar attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. @@ -6895,9 +8128,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeVarchar>; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -6907,9 +8140,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the varchar attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the varchar attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6919,9 +8152,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeVarchar>; updateVarcharAttribute( paramsOrFirst: @@ -6930,21 +8163,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeVarchar> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6957,9 +8197,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6967,9 +8207,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7032,7 +8272,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8664,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7416,8 +8703,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. @@ -7431,8 +8718,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -7441,8 +8728,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7454,8 +8741,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7467,8 +8754,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -7478,8 +8765,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -7490,8 +8777,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -7507,8 +8794,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -7519,8 +8806,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -7576,7 +8863,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7585,7 +8890,7 @@ export class Databases { * @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. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. @@ -7596,7 +8901,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7604,7 +8909,7 @@ export class Databases { * @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. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7613,7 +8918,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; createDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7621,16 +8926,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7642,14 +8947,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7694,7 +8999,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7704,7 +9038,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. @@ -7715,7 +9049,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7724,7 +9058,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7733,7 +9067,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7741,16 +9075,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7762,14 +9096,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7814,7 +9148,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7824,7 +9187,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. @@ -7836,7 +9199,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7845,7 +9208,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7855,7 +9218,7 @@ export class Databases { collectionId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; updateDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7864,17 +9227,17 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7887,7 +9250,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -7895,7 +9258,7 @@ export class Databases { 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 | null, }; } @@ -7939,7 +9302,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9444,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9603,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8192,8 +9631,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. @@ -8208,8 +9647,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -8218,8 +9657,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8232,8 +9671,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; upsertDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8245,8 +9684,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8256,8 +9695,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8268,8 +9707,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8285,8 +9724,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8297,8 +9736,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8352,7 +9791,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8362,8 +9819,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. @@ -8378,8 +9835,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -8388,8 +9845,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8402,8 +9859,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; updateDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8415,8 +9872,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8426,8 +9883,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8438,8 +9895,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8455,8 +9912,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8467,8 +9924,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8522,7 +9979,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8650,8 +10125,8 @@ export class Databases { * @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.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. + * @param {number | null} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. @@ -8664,8 +10139,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Decrement a specific attribute of a document by a given value. @@ -8675,8 +10150,8 @@ export class Databases { * @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} 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. + * @param {number | null} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8689,8 +10164,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Document>; decrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8702,11 +10177,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8714,8 +10196,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -8729,8 +10211,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8739,8 +10221,8 @@ export class Databases { 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, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8798,7 +10280,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8809,8 +10309,8 @@ export class Databases { * @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. + * @param {number | null} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. @@ -8823,8 +10323,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Increment a specific attribute of a document by a given value. @@ -8834,8 +10334,8 @@ export class Databases { * @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. + * @param {number | null} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8848,8 +10348,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Document>; incrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8861,11 +10361,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8873,8 +10380,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -8888,8 +10395,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8898,8 +10405,8 @@ export class Databases { 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, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8957,7 +10464,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,12 +10592,42 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9096,7 +10651,7 @@ export class Databases { }): Promise<Models.Index>; /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9234,7 +10789,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10898,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..8d1f7f6 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,69 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class DocumentsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class DocumentsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class DocumentsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1384,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -988,7 +1396,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1000,7 +1408,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -1013,7 +1421,7 @@ export class DocumentsDB { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -1025,7 +1433,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1035,7 +1443,7 @@ export class DocumentsDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1046,7 +1454,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1062,7 +1470,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1073,7 +1481,7 @@ export class DocumentsDB { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1136,7 +1544,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1660,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1848,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2097,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2295,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2430,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2578,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2731,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2872,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +3030,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3217,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3404,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3696,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3872,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3999,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4195,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4303,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3570,33 +4419,33 @@ export class DocumentsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3605,12 +4454,12 @@ export class DocumentsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3637,7 +4486,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4646,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4733,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4817,51 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..12834f0 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,62 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + domains: [], + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +199,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +334,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +443,35 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + prices: [], + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +524,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +699,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +803,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +904,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +1000,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1091,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1185,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1276,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1370,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1461,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1555,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1646,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1740,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1829,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1923,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2031,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2193,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2359,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2510,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2676,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2829,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2999,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3150,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3316,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3473,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3635,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3786,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3952,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4124,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4303,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4454,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4622,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4822,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5066,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5216,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5384,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5485,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5659,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5760,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5906,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..baf425d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,32 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + embeddings: [], + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..75e54d4 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,79 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + functions: [], + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +180,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +197,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -150,6 +224,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise<Models.Function>; /** * 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. @@ -159,7 +234,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +251,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +279,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise<Models.Function>; create( paramsOrFirst: @@ -229,6 +306,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +331,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise<Models.Function> { let params: { @@ -278,6 +357,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +388,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +414,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +440,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +522,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +533,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +645,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + runtimes: [], + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + supports: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +743,33 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +824,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +896,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -640,15 +904,17 @@ export class Functions { * @param {string} params.commands - Build Commands. * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the function deployments. - * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} params.buildSpecification - Build specification for the function deployments. + * @param {string | null} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} params.emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -666,15 +932,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }): Promise<Models.Function>; /** * Update function by its unique ID. @@ -684,7 +952,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -692,15 +960,17 @@ export class Functions { * @param {string} commands - Build Commands. * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the function deployments. - * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} buildSpecification - Build specification for the function deployments. + * @param {string | null} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -719,15 +989,17 @@ export class Functions { commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, - runtimeSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, + runtimeSpecification?: string | null, deploymentRetention?: number, + interval?: number | null, + emailEnabled?: boolean | null, ): Promise<Models.Function>; update( paramsOrFirst: @@ -745,15 +1017,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; } | string, ...rest: [ @@ -769,15 +1043,17 @@ export class Functions { string?, ProjectKeyScopes[]?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, number?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.Function> { let params: { @@ -794,15 +1070,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; if ( @@ -824,15 +1102,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; } else { params = { @@ -849,15 +1129,17 @@ export class Functions { commands: rest[9] as string, scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, + providerRepositoryId: rest[12] as string | null, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - providerBranches: rest[16] as string[], - providerPaths: rest[17] as string[], - buildSpecification: rest[18] as string, - runtimeSpecification: rest[19] as string, + providerBranches: rest[16] as string[] | null, + providerPaths: rest[17] as string[] | null, + buildSpecification: rest[18] as string | null, + runtimeSpecification: rest[19] as string | null, deploymentRetention: rest[20] as number, + interval: rest[21] as number | null, + emailEnabled: rest[22] as boolean | null, }; } @@ -883,6 +1165,8 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; + const emailEnabled = params.emailEnabled; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1243,12 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof emailEnabled !== 'undefined') { + apiPayload['emailEnabled'] = emailEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1257,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1450,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1615,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1910,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2120,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2274,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2387,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2691,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2812,59 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2876,7 @@ export class Functions { * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ @@ -2190,7 +2887,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Execution>; /** * 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. @@ -2201,7 +2898,7 @@ export class Functions { * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2213,7 +2910,7 @@ export class Functions { xpath?: string, method?: ExecutionMethod, headers?: object, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Execution>; createExecution( paramsOrFirst: @@ -2224,7 +2921,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; } | string, ...rest: [ @@ -2233,7 +2930,7 @@ export class Functions { string?, ExecutionMethod?, object?, - string?, + (string | null)?, ] ): Promise<Models.Execution> { let params: { @@ -2243,7 +2940,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -2258,7 +2955,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -2268,7 +2965,7 @@ 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 | null, }; } @@ -2315,7 +3012,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3126,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3322,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3480,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3572,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2752,27 +3599,27 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2780,28 +3627,33 @@ export class Functions { updateVariable( functionId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2812,17 +3664,17 @@ export class Functions { params = (paramsOrFirst || {}) as { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2862,7 +3714,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..ca069ee 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + localeCodes: [], + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +170,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + continents: [], + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +245,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +320,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +397,32 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + phones: [], + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +473,36 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + currencies: [], + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +553,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + languages: [], + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..4ea6d8c 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,39 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + messages: [], + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,12 +137,12 @@ export class Messaging { * @param {string[]} params.targets - List of Targets IDs. * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -118,12 +155,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }): Promise<Models.Message>; /** * Create a new email message. @@ -136,12 +173,12 @@ export class Messaging { * @param {string[]} targets - List of Targets IDs. * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -155,12 +192,12 @@ export class Messaging { targets?: string[], cc?: string[], bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, + attachments?: string[] | null, draft?: boolean, html?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, + replyToEmail?: string, + replyToName?: string, ): Promise<Models.Message>; createEmail( paramsOrFirst: @@ -173,12 +210,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -189,11 +226,11 @@ export class Messaging { string[]?, string[]?, string[]?, - string[]?, - string?, - string?, + (string[] | null)?, boolean?, boolean?, + (string | null)?, + string?, string?, ] ): Promise<Models.Message> { @@ -206,12 +243,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -228,12 +265,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -245,12 +282,12 @@ export class Messaging { targets: rest[4] as string[], cc: rest[5] as string[], bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + attachments: rest[7] as string[] | null, + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string | null, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -263,11 +300,11 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; - const replyToEmail = params.replyToEmail; - const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -312,12 +349,6 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } - if (typeof replyToEmail !== 'undefined') { - apiPayload['replyToEmail'] = replyToEmail; - } - if (typeof replyToName !== 'undefined') { - apiPayload['replyToName'] = replyToName; - } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -327,6 +358,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -335,7 +372,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,126 +401,126 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.subject - Email Subject. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {string[]} params.cc - Array of target IDs to be added as CC. - * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} params.draft - Is message a draft - * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.subject - Email Subject. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {boolean | null} params.html - Is content of type HTML + * @param {string[] | null} params.cc - Array of target IDs to be added as CC. + * @param {string[] | null} params.bcc - Array of target IDs to be added as BCC. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.Message>; /** * 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} subject - Email Subject. - * @param {string} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {string[]} cc - Array of target IDs to be added as CC. - * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} draft - Is message a draft - * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} subject - Email Subject. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {boolean | null} html - Is content of type HTML + * @param {string[] | null} cc - Array of target IDs to be added as CC. + * @param {string[] | null} bcc - Array of target IDs to be added as BCC. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateEmail( messageId: string, - subject?: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - cc?: string[], - bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, - draft?: boolean, - html?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + subject?: string | null, + content?: string | null, + draft?: boolean | null, + html?: boolean | null, + cc?: string[] | null, + bcc?: string[] | null, + scheduledAt?: string | null, + attachments?: string[] | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.Message>; updateEmail( paramsOrFirst: | { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string?, - string?, - boolean?, - boolean?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.Message> { let params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -472,53 +530,53 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - subject: rest[0] as string, - content: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - cc: rest[5] as string[], - bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + subject: rest[3] as string | null, + content: rest[4] as string | null, + draft: rest[5] as boolean | null, + html: rest[6] as boolean | null, + cc: rest[7] as string[] | null, + bcc: rest[8] as string[] | null, + scheduledAt: rest[9] as string | null, + attachments: rest[10] as string[] | null, + replyToEmail: rest[11] as string | null, + replyToName: rest[12] as string | null, }; } const messageId = params.messageId; - const subject = params.subject; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; const cc = params.cc; const bcc = params.bcc; + const scheduledAt = params.scheduledAt; const attachments = params.attachments; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - const draft = params.draft; - const html = params.html; - const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -529,12 +587,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof subject !== 'undefined') { - apiPayload['subject'] = subject; - } - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -544,12 +596,27 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof subject !== 'undefined') { + apiPayload['subject'] = subject; + } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + if (typeof draft !== 'undefined') { + apiPayload['draft'] = draft; + } + if (typeof html !== 'undefined') { + apiPayload['html'] = html; + } if (typeof cc !== 'undefined') { apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { apiPayload['bcc'] = bcc; } + if (typeof scheduledAt !== 'undefined') { + apiPayload['scheduledAt'] = scheduledAt; + } if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } @@ -559,15 +626,6 @@ export class Messaging { if (typeof replyToName !== 'undefined') { apiPayload['replyToName'] = replyToName; } - if (typeof draft !== 'undefined') { - apiPayload['draft'] = draft; - } - if (typeof html !== 'undefined') { - apiPayload['html'] = html; - } - if (typeof scheduledAt !== 'undefined') { - apiPayload['scheduledAt'] = scheduledAt; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -576,7 +634,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -588,7 +667,7 @@ export class Messaging { * @param {string[]} params.topics - List of Topic IDs. * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional key-value pair data for push notification. + * @param {object | null} params.data - Additional key-value pair data for push notification. * @param {string} params.action - Action for push notification. * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. @@ -597,7 +676,7 @@ export class Messaging { * @param {string} params.tag - Tag for push notification. Available only for Android Platform. * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -612,7 +691,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -621,7 +700,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -636,7 +715,7 @@ export class Messaging { * @param {string[]} topics - List of Topic IDs. * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional key-value pair data for push notification. + * @param {object | null} data - Additional key-value pair data for push notification. * @param {string} action - Action for push notification. * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. @@ -645,7 +724,7 @@ export class Messaging { * @param {string} tag - Tag for push notification. Available only for Android Platform. * @param {number} badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -661,7 +740,7 @@ export class Messaging { topics?: string[], users?: string[], targets?: string[], - data?: object, + data?: object | null, action?: string, image?: string, icon?: string, @@ -670,7 +749,7 @@ export class Messaging { tag?: string, badge?: number, draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, @@ -685,7 +764,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -694,7 +773,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -707,7 +786,7 @@ export class Messaging { string[]?, string[]?, string[]?, - object?, + (object | null)?, string?, string?, string?, @@ -716,7 +795,7 @@ export class Messaging { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, MessagePriority?, @@ -730,7 +809,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -739,7 +818,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -758,7 +837,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -767,7 +846,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -781,7 +860,7 @@ export class Messaging { topics: rest[2] as string[], users: rest[3] as string[], targets: rest[4] as string[], - data: rest[5] as object, + data: rest[5] as object | null, action: rest[6] as string, image: rest[7] as string, icon: rest[8] as string, @@ -790,7 +869,7 @@ export class Messaging { tag: rest[11] as string, badge: rest[12] as number, draft: rest[13] as boolean, - scheduledAt: rest[14] as string, + scheduledAt: rest[14] as string | null, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, @@ -893,7 +972,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -901,168 +1001,168 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.title - Title for push notification. - * @param {string} params.body - Body for push notification. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional Data for push notification. - * @param {string} params.action - Action for push notification. - * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} params.color - Color for push notification. Available only for Android platforms. - * @param {string} params.tag - Tag for push notification. Available only for Android platforms. - * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.title - Title for push notification. + * @param {string | null} params.body - Body for push notification. + * @param {object | null} params.data - Additional Data for push notification. + * @param {string | null} params.action - Action for push notification. + * @param {string | null} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} params.color - Color for push notification. Available only for Android platforms. + * @param {string | null} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }): Promise<Models.Message>; /** * 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} title - Title for push notification. - * @param {string} body - Body for push notification. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional Data for push notification. - * @param {string} action - Action for push notification. - * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} color - Color for push notification. Available only for Android platforms. - * @param {string} tag - Tag for push notification. Available only for Android platforms. - * @param {number} badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} title - Title for push notification. + * @param {string | null} body - Body for push notification. + * @param {object | null} data - Additional Data for push notification. + * @param {string | null} action - Action for push notification. + * @param {string | null} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} color - Color for push notification. Available only for Android platforms. + * @param {string | null} tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePush( 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, - channelId?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + title?: string | null, + body?: string | null, + data?: object | null, + action?: string | null, + image?: string | null, + icon?: string | null, + sound?: string | null, + color?: string | null, + tag?: string | null, + badge?: number | null, + draft?: boolean | null, + scheduledAt?: string | null, + contentAvailable?: boolean | null, + critical?: boolean | null, + priority?: MessagePriority | null, + channelId?: string | null, ): Promise<Models.Message>; updatePush( 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - object?, - string?, - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string?, - boolean?, - boolean?, - MessagePriority?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (object | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (MessagePriority | null)?, + (string | null)?, ] ): Promise<Models.Message> { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; if ( @@ -1072,57 +1172,57 @@ export class Messaging { ) { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - title: rest[0] as string, - body: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - data: rest[5] as object, - action: rest[6] as string, - image: rest[7] as string, - icon: rest[8] as string, - sound: rest[9] as string, - color: rest[10] as string, - tag: rest[11] as string, - badge: rest[12] as number, - draft: rest[13] as boolean, - scheduledAt: rest[14] as string, - contentAvailable: rest[15] as boolean, - critical: rest[16] as boolean, - priority: rest[17] as MessagePriority, - channelId: rest[18] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + title: rest[3] as string | null, + body: rest[4] as string | null, + data: rest[5] as object | null, + action: rest[6] as string | null, + image: rest[7] as string | null, + icon: rest[8] as string | null, + sound: rest[9] as string | null, + color: rest[10] as string | null, + tag: rest[11] as string | null, + badge: rest[12] as number | null, + draft: rest[13] as boolean | null, + scheduledAt: rest[14] as string | null, + contentAvailable: rest[15] as boolean | null, + critical: rest[16] as boolean | null, + priority: rest[17] as MessagePriority | null, + channelId: rest[18] as string | null, }; } const messageId = params.messageId; - const title = params.title; - const body = params.body; const topics = params.topics; const users = params.users; const targets = params.targets; + const title = params.title; + const body = params.body; const data = params.data; const action = params.action; const image = params.image; @@ -1147,12 +1247,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof title !== 'undefined') { - apiPayload['title'] = title; - } - if (typeof body !== 'undefined') { - apiPayload['body'] = body; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1162,6 +1256,12 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof title !== 'undefined') { + apiPayload['title'] = title; + } + if (typeof body !== 'undefined') { + apiPayload['body'] = body; + } if (typeof data !== 'undefined') { apiPayload['data'] = data; } @@ -1212,7 +1312,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1224,7 +1345,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. @@ -1236,7 +1357,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1247,7 +1368,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1259,7 +1380,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSms( paramsOrFirst: @@ -1270,10 +1391,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1282,7 +1410,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1297,7 +1425,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1307,7 +1435,7 @@ 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 | null, }; } @@ -1359,7 +1487,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1371,7 +1520,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -1382,7 +1531,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1393,7 +1542,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1405,7 +1554,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSMS( paramsOrFirst: @@ -1416,10 +1565,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1428,7 +1584,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1443,7 +1599,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1453,7 +1609,7 @@ 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 | null, }; } @@ -1505,7 +1661,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1513,71 +1690,78 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ updateSms(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSms( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSms( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1587,30 +1771,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1623,9 +1807,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1635,6 +1816,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1649,7 +1833,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1657,70 +1862,77 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSMS(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSMS( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSMS( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1730,30 +1942,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1766,9 +1978,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1778,6 +1987,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1792,7 +2004,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2082,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2240,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2349,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + providers: [], + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2078,7 +2392,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. @@ -2091,7 +2405,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2103,7 +2417,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2116,7 +2430,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createApnsProvider( paramsOrFirst: @@ -2128,7 +2442,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2138,7 +2452,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2149,7 +2463,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2165,7 +2479,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2176,7 +2490,7 @@ 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 | null, }; } @@ -2230,7 +2544,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2243,7 +2576,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -2255,7 +2588,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2267,7 +2600,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2280,7 +2613,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createAPNSProvider( paramsOrFirst: @@ -2292,7 +2625,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2302,7 +2635,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2313,7 +2646,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2329,7 +2662,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2340,7 +2673,7 @@ 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 | null, }; } @@ -2394,7 +2727,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2402,12 +2754,12 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. @@ -2415,24 +2767,24 @@ export class Messaging { updateApnsProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2440,45 +2792,45 @@ export class Messaging { updateApnsProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateApnsProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2489,23 +2841,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2556,7 +2908,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2564,36 +2935,36 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAPNSProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2601,45 +2972,45 @@ export class Messaging { updateAPNSProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateAPNSProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2650,23 +3021,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2717,7 +3088,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2725,27 +3115,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createAppwriteProvider(params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Create a new Appwrite push provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2753,28 +3143,33 @@ export class Messaging { createAppwriteProvider( providerId: string, name: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; createAppwriteProvider( paramsOrFirst: | { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2785,17 +3180,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2837,7 +3232,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,27 +3259,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAppwriteProvider(params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Update an Appwrite push provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2873,28 +3287,33 @@ export class Messaging { updateAppwriteProvider( providerId: string, name?: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; updateAppwriteProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2905,17 +3324,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2954,7 +3373,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2962,8 +3400,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. @@ -2971,16 +3409,16 @@ export class Messaging { createFcmProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2988,25 +3426,25 @@ export class Messaging { createFcmProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFcmProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3017,15 +3455,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3063,7 +3501,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3071,24 +3528,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFCMProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3096,25 +3553,25 @@ export class Messaging { createFCMProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFCMProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3125,15 +3582,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3171,7 +3628,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,8 +3655,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. @@ -3188,16 +3664,16 @@ export class Messaging { updateFcmProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3205,25 +3681,25 @@ export class Messaging { updateFcmProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFcmProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3234,15 +3710,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3277,7 +3753,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3285,24 +3780,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFCMProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3310,25 +3805,25 @@ export class Messaging { updateFCMProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFCMProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3339,15 +3834,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3382,7 +3877,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3392,12 +3906,12 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.isEuRegion - Set as EU region. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3406,12 +3920,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Mailgun provider. @@ -3420,12 +3934,12 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean | null} isEuRegion - Set as EU region. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3435,12 +3949,12 @@ export class Messaging { name: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, + isEuRegion?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMailgunProvider( paramsOrFirst: @@ -3449,24 +3963,24 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -3474,12 +3988,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3492,12 +4006,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3505,12 +4019,12 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, + isEuRegion: rest[3] as boolean | null, fromName: rest[4] as string, 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 | null, }; } @@ -3572,7 +4086,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3582,8 +4115,8 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3596,8 +4129,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3610,8 +4143,8 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} isEuRegion - Set as EU region. + * @param {boolean | null} enabled - Set as enabled. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3625,8 +4158,8 @@ export class Messaging { name?: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, - enabled?: boolean, + isEuRegion?: boolean | null, + enabled?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, @@ -3639,8 +4172,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3651,8 +4184,8 @@ export class Messaging { string?, string?, string?, - boolean?, - boolean?, + (boolean | null)?, + (boolean | null)?, string?, string?, string?, @@ -3664,8 +4197,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3682,8 +4215,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3695,8 +4228,8 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, - enabled: rest[4] as boolean, + isEuRegion: rest[3] as boolean | null, + enabled: rest[4] as boolean | null, fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, @@ -3759,7 +4292,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3770,7 +4322,7 @@ export class Messaging { * @param {string} params.templateId - Msg91 template ID * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3780,7 +4332,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new MSG91 provider. @@ -3790,7 +4342,7 @@ export class Messaging { * @param {string} templateId - Msg91 template ID * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3801,7 +4353,7 @@ export class Messaging { templateId?: string, senderId?: string, authKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMsg91Provider( paramsOrFirst: @@ -3811,10 +4363,10 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -3822,7 +4374,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3836,7 +4388,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3845,7 +4397,7 @@ 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 | null, }; } @@ -3891,7 +4443,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3899,7 +4470,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.templateId - Msg91 template ID. * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. @@ -3909,7 +4480,7 @@ export class Messaging { updateMsg91Provider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3919,7 +4490,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} templateId - Msg91 template ID. * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. @@ -3930,7 +4501,7 @@ export class Messaging { updateMsg91Provider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, templateId?: string, senderId?: string, authKey?: string, @@ -3940,18 +4511,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3965,7 +4536,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3974,7 +4545,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, templateId: rest[2] as string, senderId: rest[3] as string, authKey: rest[4] as string, @@ -4020,7 +4591,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4033,7 +4623,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4045,7 +4635,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Resend provider. @@ -4057,7 +4647,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4070,7 +4660,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createResendProvider( paramsOrFirst: @@ -4082,7 +4672,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4092,7 +4682,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4103,7 +4693,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4119,7 +4709,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4130,7 +4720,7 @@ 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 | null, }; } @@ -4184,7 +4774,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4192,7 +4801,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Resend API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4204,7 +4813,7 @@ export class Messaging { updateResendProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4216,7 +4825,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Resend API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4229,7 +4838,7 @@ export class Messaging { updateResendProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4241,7 +4850,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4251,7 +4860,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4262,7 +4871,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4278,7 +4887,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4289,7 +4898,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4345,7 +4954,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4358,7 +4986,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4370,7 +4998,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Sendgrid provider. @@ -4382,7 +5010,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4395,7 +5023,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSendgridProvider( paramsOrFirst: @@ -4407,7 +5035,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4417,7 +5045,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4428,7 +5056,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4444,7 +5072,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4455,7 +5083,7 @@ 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 | null, }; } @@ -4509,7 +5137,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4517,7 +5164,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Sendgrid API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4529,7 +5176,7 @@ export class Messaging { updateSendgridProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4541,7 +5188,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Sendgrid API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4554,7 +5201,7 @@ export class Messaging { updateSendgridProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4566,7 +5213,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4576,7 +5223,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4587,7 +5234,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4603,7 +5250,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4614,7 +5261,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4670,7 +5317,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4685,7 +5351,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4699,7 +5365,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Amazon SES provider. @@ -4713,7 +5379,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4728,7 +5394,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSesProvider( paramsOrFirst: @@ -4742,7 +5408,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4754,7 +5420,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4767,7 +5433,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4785,7 +5451,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4798,7 +5464,7 @@ 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 | null, }; } @@ -4860,7 +5526,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4868,7 +5553,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accessKey - AWS access key ID. * @param {string} params.secretKey - AWS secret access key. * @param {string} params.region - AWS region, for example us-east-1. @@ -4882,7 +5567,7 @@ export class Messaging { updateSesProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4896,7 +5581,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accessKey - AWS access key ID. * @param {string} secretKey - AWS secret access key. * @param {string} region - AWS region, for example us-east-1. @@ -4911,7 +5596,7 @@ export class Messaging { updateSesProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accessKey?: string, secretKey?: string, region?: string, @@ -4925,7 +5610,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4937,7 +5622,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4950,7 +5635,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4968,7 +5653,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4981,7 +5666,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accessKey: rest[2] as string, secretKey: rest[3] as string, region: rest[4] as string, @@ -5047,7 +5732,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5066,7 +5770,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. @@ -5085,7 +5789,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5103,7 +5807,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5122,7 +5826,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSmtpProvider( paramsOrFirst: @@ -5140,7 +5844,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5156,7 +5860,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5173,7 +5877,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5195,7 +5899,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5212,7 +5916,7 @@ 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 | null, }; } @@ -5293,7 +5997,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5312,7 +6035,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5330,7 +6053,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5348,7 +6071,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5367,7 +6090,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSMTPProvider( paramsOrFirst: @@ -5385,7 +6108,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5401,7 +6124,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5418,7 +6141,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5440,7 +6163,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5457,7 +6180,7 @@ 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 | null, }; } @@ -5538,7 +6261,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5547,17 +6289,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. @@ -5566,17 +6308,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5584,17 +6326,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5603,17 +6345,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSmtpProvider( paramsOrFirst: @@ -5621,50 +6363,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5676,34 +6418,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -5778,7 +6520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5787,17 +6548,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5805,17 +6566,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5823,17 +6584,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5842,17 +6603,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSMTPProvider( paramsOrFirst: @@ -5860,50 +6621,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5915,34 +6676,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -6017,7 +6778,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6028,7 +6808,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6038,7 +6818,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Telesign provider. @@ -6048,7 +6828,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6059,7 +6839,7 @@ export class Messaging { from?: string, customerId?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTelesignProvider( paramsOrFirst: @@ -6069,10 +6849,10 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6080,7 +6860,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6094,7 +6874,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6103,7 +6883,7 @@ 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 | null, }; } @@ -6149,7 +6929,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6157,7 +6956,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. * @param {string} params.from - Sender number. @@ -6167,7 +6966,7 @@ export class Messaging { updateTelesignProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6177,7 +6976,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. * @param {string} from - Sender number. @@ -6188,7 +6987,7 @@ export class Messaging { updateTelesignProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, customerId?: string, apiKey?: string, from?: string, @@ -6198,18 +6997,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6223,7 +7022,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6232,7 +7031,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, customerId: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6278,7 +7077,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6289,7 +7107,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6299,7 +7117,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Textmagic provider. @@ -6309,7 +7127,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6320,7 +7138,7 @@ export class Messaging { from?: string, username?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTextmagicProvider( paramsOrFirst: @@ -6330,10 +7148,10 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6341,7 +7159,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6355,7 +7173,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6364,7 +7182,7 @@ 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 | null, }; } @@ -6410,7 +7228,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6418,7 +7255,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. * @param {string} params.from - Sender number. @@ -6428,7 +7265,7 @@ export class Messaging { updateTextmagicProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6438,7 +7275,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. * @param {string} from - Sender number. @@ -6449,7 +7286,7 @@ export class Messaging { updateTextmagicProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, username?: string, apiKey?: string, from?: string, @@ -6459,18 +7296,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6484,7 +7321,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6493,7 +7330,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, username: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6539,7 +7376,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6550,7 +7406,7 @@ export class Messaging { * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6560,7 +7416,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Twilio provider. @@ -6570,7 +7426,7 @@ export class Messaging { * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6581,7 +7437,7 @@ export class Messaging { from?: string, accountSid?: string, authToken?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTwilioProvider( paramsOrFirst: @@ -6591,10 +7447,10 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6602,7 +7458,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6616,7 +7472,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6625,7 +7481,7 @@ 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 | null, }; } @@ -6671,7 +7527,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6679,7 +7554,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6689,7 +7564,7 @@ export class Messaging { updateTwilioProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6699,7 +7574,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6710,7 +7585,7 @@ export class Messaging { updateTwilioProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accountSid?: string, authToken?: string, from?: string, @@ -6720,18 +7595,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6745,7 +7620,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6754,7 +7629,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accountSid: rest[2] as string, authToken: rest[3] as string, from: rest[4] as string, @@ -6800,7 +7675,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6811,7 +7705,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6821,7 +7715,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Vonage provider. @@ -6831,7 +7725,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6842,7 +7736,7 @@ export class Messaging { from?: string, apiKey?: string, apiSecret?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createVonageProvider( paramsOrFirst: @@ -6852,10 +7746,10 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6863,7 +7757,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6877,7 +7771,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6886,7 +7780,7 @@ 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 | null, }; } @@ -6932,7 +7826,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6940,7 +7853,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. * @param {string} params.from - Sender number. @@ -6950,7 +7863,7 @@ export class Messaging { updateVonageProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -6960,7 +7873,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. * @param {string} from - Sender number. @@ -6971,7 +7884,7 @@ export class Messaging { updateVonageProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, apiSecret?: string, from?: string, @@ -6981,18 +7894,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7006,7 +7919,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7015,7 +7928,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, apiSecret: rest[3] as string, from: rest[4] as string, @@ -7061,7 +7974,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +8050,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8204,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + topics: [], + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7262,8 +8243,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ @@ -7271,8 +8252,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Create a new topic. @@ -7280,8 +8261,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7290,8 +8271,8 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, - expiry?: number, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; createTopic( paramsOrFirst: @@ -7299,18 +8280,18 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [string?, string[]?, (number | null)?, (number | null)?] ): Promise<Models.Topic> { let params: { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7322,16 +8303,16 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7373,7 +8354,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7438,58 +8457,63 @@ export class Messaging { * * * @param {string} params.topicId - Topic ID. - * @param {string} params.name - Topic Name. - * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} params.name - Topic Name. + * @param {string[] | null} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Update a topic by its unique ID. * * * @param {string} topicId - Topic ID. - * @param {string} name - Topic Name. - * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} name - Topic Name. + * @param {string[] | null} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. */ updateTopic( topicId: string, - name?: string, - subscribe?: string[], - qos?: number, - expiry?: number, + name?: string | null, + subscribe?: string[] | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; updateTopic( paramsOrFirst: | { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [ + (string | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Topic> { let params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7499,18 +8523,18 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, - name: rest[0] as string, - subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + name: rest[0] as string | null, + subscribe: rest[1] as string[] | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7549,7 +8573,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8750,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + subscribers: [], + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8875,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8972,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..169782c 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,74 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mongo { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mongo { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mongo { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mongo { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mongo { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,40 +2620,59 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2045,12 +2681,12 @@ export class Mongo { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2077,7 +2713,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2861,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2177,21 +2925,21 @@ export class Mongo { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2199,18 +2947,22 @@ export class Mongo { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2221,13 +2973,13 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2263,7 +3015,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3175,37 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3262,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3332,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,35 +3477,78 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2633,28 +3556,45 @@ export class Mongo { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -2665,17 +3605,23 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -2684,6 +3630,9 @@ export class Mongo { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -2706,6 +3655,15 @@ export class Mongo { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2714,7 +3672,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3767,129 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mongo/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3944,52 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +4067,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..13e7de1 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,74 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mysql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mysql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mysql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mysql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Mysql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,40 +2747,68 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2153,12 +2817,12 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2185,7 +2849,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2997,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2285,21 +3061,21 @@ export class Mysql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2307,18 +3083,22 @@ export class Mysql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2329,13 +3109,13 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2371,7 +3151,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3311,37 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3398,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,97 +3468,118 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2689,26 +3589,26 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2763,7 +3663,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3741,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,35 +3886,78 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2972,28 +3965,45 @@ export class Mysql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3004,17 +4014,23 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3023,6 +4039,9 @@ export class Mysql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3045,6 +4064,15 @@ export class Mysql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3053,7 +4081,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4176,129 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mysql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4353,52 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4476,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..84e0c31 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -347,9 +377,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -365,9 +395,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -383,9 +413,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -402,9 +432,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -420,9 +450,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -436,9 +466,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, string?, ] @@ -453,9 +483,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -476,9 +506,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -493,9 +523,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2DeviceAuthorization>; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2DeviceAuthorization>; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise<Models.Oauth2DeviceAuthorization> { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + organizations: [], + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -999,9 +1140,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1016,9 +1157,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2PAR>; /** @@ -1033,9 +1174,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1051,9 +1192,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2PAR>; createPAR( @@ -1068,9 +1209,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1083,9 +1224,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, ] ): Promise<Models.Oauth2PAR> { @@ -1099,9 +1240,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1120,9 +1261,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1136,9 +1277,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1363,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1457,32 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1540,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1671,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1494,7 +1685,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2Token>; /** @@ -1508,7 +1699,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1523,7 +1714,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2Token>; createToken( @@ -1537,7 +1728,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1740,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise<Models.Oauth2Token> { @@ -1562,7 +1753,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1771,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1784,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1846,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..37dffa7 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +330,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,40 +407,64 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. */ updateInstallation( installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: - { installationId: string; authorizationDetails?: string } | string, - ...rest: [string?] + | { installationId: string; authorizationDetails?: string | null } + | string, + ...rest: [(string | null)?] ): Promise<Models.AppInstallation> { - let params: { installationId: string; authorizationDetails?: string }; + let params: { + installationId: string; + authorizationDetails?: string | null; + }; if ( paramsOrFirst && @@ -345,12 +473,12 @@ export class Organization { ) { params = (paramsOrFirst || {}) as { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string, + authorizationDetails: rest[0] as string | null, }; } @@ -377,7 +505,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +660,44 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +824,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +905,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1007,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1168,92 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1340,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1469,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1616,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1827,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1964,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2052,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1441,7 +2082,7 @@ export class Organization { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -1450,7 +2091,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -1459,7 +2100,7 @@ export class Organization { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1469,7 +2110,7 @@ export class Organization { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateProjectKey( paramsOrFirst: @@ -1478,17 +2119,17 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { projectId: string; keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -1501,7 +2142,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } else { params = { @@ -1509,7 +2150,7 @@ export class Organization { keyId: rest[0] as string, name: rest[1] as string, scopes: rest[2] as ProjectKeyScopes[], - expire: rest[3] as string, + expire: rest[3] as string | null, }; } @@ -1553,7 +2194,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..aafaf2d 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,74 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Postgresql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Postgresql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Postgresql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Postgresql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Postgresql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,7 +2747,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2834,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + metadata: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2937,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,40 +3070,96 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2365,12 +3168,12 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2397,7 +3200,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3348,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2497,21 +3412,21 @@ export class Postgresql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2519,18 +3434,22 @@ export class Postgresql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2541,13 +3460,13 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2583,7 +3502,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3662,37 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3749,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,97 +3819,118 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2901,26 +3940,26 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2975,7 +4014,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4092,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,35 +4237,78 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3184,28 +4316,45 @@ export class Postgresql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3216,17 +4365,23 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3235,6 +4390,9 @@ export class Postgresql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3257,6 +4415,15 @@ export class Postgresql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3265,7 +4432,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4527,129 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4704,52 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4827,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..edc7fe1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,35 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + presences: [], + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +176,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +330,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +493,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..6e554ab 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +148,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -81,7 +160,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -144,7 +223,719 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.ProjectList>; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise<Models.ProjectList>; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.ProjectList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + getEnvironment(params: { environmentId: string }): Promise<Models.Project>; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise<Models.Project>; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<Models.Project> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -209,7 +1000,38 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +1114,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +1185,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -352,7 +1214,7 @@ export class Project { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -360,7 +1222,7 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -368,7 +1230,7 @@ export class Project { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -377,7 +1239,7 @@ export class Project { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateKey( paramsOrFirst: @@ -385,16 +1247,16 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -406,14 +1268,14 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } 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 | null, }; } @@ -452,7 +1314,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +1440,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +1582,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + mockNumbers: [], + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1676,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1827,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1962,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + providers: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -945,16 +1985,16 @@ export class Project { * @param {string} params.authorizationUrl - URL to your application with consent screen. * @param {string[]} params.scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -965,16 +2005,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }): Promise<Models.Project>; @@ -985,16 +2025,16 @@ export class Project { * @param {string} authorizationUrl - URL to your application with consent screen. * @param {string[]} scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -1006,16 +2046,16 @@ export class Project { authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], - accessTokenDuration?: number, - refreshTokenDuration?: number, - publicAccessTokenDuration?: number, - publicRefreshTokenDuration?: number, - installationAccessTokenDuration?: number, - confidentialPkce?: boolean, + accessTokenDuration?: number | null, + refreshTokenDuration?: number | null, + publicAccessTokenDuration?: number | null, + publicRefreshTokenDuration?: number | null, + installationAccessTokenDuration?: number | null, + confidentialPkce?: boolean | null, verificationUrl?: string, - userCodeLength?: number, + userCodeLength?: number | null, userCodeFormat?: string, - deviceCodeDuration?: number, + deviceCodeDuration?: number | null, defaultScopes?: string[], installationScopes?: string[], ): Promise<Models.Project>; @@ -1026,16 +2066,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; } @@ -1044,16 +2084,16 @@ export class Project { string?, string[]?, string[]?, - number?, - number?, - number?, - number?, - number?, - boolean?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, string?, - number?, + (number | null)?, string?, - number?, + (number | null)?, string[]?, string[]?, ] @@ -1063,16 +2103,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1087,16 +2127,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1106,16 +2146,16 @@ export class Project { authorizationUrl: rest[0] as string, scopes: rest[1] as string[], authorizationDetailsTypes: rest[2] as string[], - accessTokenDuration: rest[3] as number, - refreshTokenDuration: rest[4] as number, - publicAccessTokenDuration: rest[5] as number, - publicRefreshTokenDuration: rest[6] as number, - installationAccessTokenDuration: rest[7] as number, - confidentialPkce: rest[8] as boolean, + accessTokenDuration: rest[3] as number | null, + refreshTokenDuration: rest[4] as number | null, + publicAccessTokenDuration: rest[5] as number | null, + publicRefreshTokenDuration: rest[6] as number | null, + installationAccessTokenDuration: rest[7] as number | null, + confidentialPkce: rest[8] as boolean | null, verificationUrl: rest[9] as string, - userCodeLength: rest[10] as number, + userCodeLength: rest[10] as number | null, userCodeFormat: rest[11] as string, - deviceCodeDuration: rest[12] as number, + deviceCodeDuration: rest[12] as number | null, defaultScopes: rest[13] as string[], installationScopes: rest[14] as string[], }; @@ -1208,48 +2248,127 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Amazon configuration. * - * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} */ updateOAuth2Amazon(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Amazon>; /** * Update the project OAuth2 Amazon configuration. * - * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Amazon( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Amazon>; updateOAuth2Amazon( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Amazon> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1259,15 +2378,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1293,76 +2412,99 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Apple configuration. * - * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} */ updateOAuth2Apple(params?: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Apple>; /** * Update the project OAuth2 Apple configuration. * - * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Apple( - serviceId?: string, - keyId?: string, - teamId?: string, - p8File?: string, - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + serviceId?: string | null, + keyId?: string | null, + teamId?: string | null, + p8File?: string | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Apple>; updateOAuth2Apple( paramsOrFirst?: | { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Apple> { let params: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -1372,23 +2514,23 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - serviceId: paramsOrFirst as string, - keyId: rest[0] as string, - teamId: rest[1] as string, - p8File: rest[2] as string, - nativeClientIds: rest[3] as string[], - enabled: rest[4] as boolean, - nativeEnabled: rest[5] as boolean, + serviceId: paramsOrFirst as string | null, + keyId: rest[0] as string | null, + teamId: rest[1] as string | null, + p8File: rest[2] as string | null, + enabled: rest[3] as boolean | null, + nativeClientIds: rest[4] as string[] | null, + nativeEnabled: rest[5] as boolean | null, }; } @@ -1396,8 +2538,8 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; @@ -1413,12 +2555,12 @@ export class Project { if (typeof p8File !== 'undefined') { apiPayload['p8File'] = p8File; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -1430,48 +2572,72 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} */ updateOAuth2Appwrite(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Appwrite>; /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Appwrite( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Appwrite>; updateOAuth2Appwrite( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Appwrite> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1481,15 +2647,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1515,64 +2681,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} */ updateOAuth2Auth0(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }): Promise<Models.OAuth2Auth0>; /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Auth0( - clientId?: string, - clientSecret?: string, - endpoint?: string, - prompt?: ProjectOAuth2Auth0Prompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2Auth0Prompt[] | null, ): Promise<Models.OAuth2Auth0>; updateOAuth2Auth0( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2Auth0Prompt[] | null)?, + ] ): Promise<Models.OAuth2Auth0> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; if ( @@ -1582,27 +2769,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - prompt: rest[2] as ProjectOAuth2Auth0Prompt[], - enabled: rest[3] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1614,12 +2801,12 @@ export class Project { if (typeof endpoint !== 'undefined') { apiPayload['endpoint'] = endpoint; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1628,58 +2815,76 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Authentik configuration. * - * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} */ updateOAuth2Authentik(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Authentik>; /** * Update the project OAuth2 Authentik configuration. * - * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Authentik( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Authentik>; updateOAuth2Authentik( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Authentik> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -1689,17 +2894,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -1729,48 +2934,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} */ updateOAuth2Autodesk(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Autodesk>; /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Autodesk( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Autodesk>; updateOAuth2Autodesk( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Autodesk> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1780,15 +3006,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1814,44 +3040,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} */ updateOAuth2Bitbucket(params?: { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitbucket>; /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitbucket( - key?: string, - secret?: string, - enabled?: boolean, + key?: string | null, + secret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitbucket>; updateOAuth2Bitbucket( paramsOrFirst?: - { key?: string; secret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitbucket> { - let params: { key?: string; secret?: string; enabled?: boolean }; + let params: { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -1860,15 +3111,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }; } else { params = { - key: paramsOrFirst as string, - secret: rest[0] as string, - enabled: rest[1] as boolean, + key: paramsOrFirst as string | null, + secret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1894,48 +3145,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitly configuration. * - * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} */ updateOAuth2Bitly(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitly>; /** * Update the project OAuth2 Bitly configuration. * - * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitly( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitly>; updateOAuth2Bitly( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitly> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1945,15 +3216,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1979,48 +3250,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Box configuration. * - * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} */ updateOAuth2Box(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Box>; /** * Update the project OAuth2 Box configuration. * - * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Box( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Box>; updateOAuth2Box( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Box> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2030,15 +3321,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2064,48 +3355,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} */ updateOAuth2Cloudflare(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Cloudflare>; /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Cloudflare( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Cloudflare>; updateOAuth2Cloudflare( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Cloudflare> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2115,15 +3426,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2149,44 +3460,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} */ updateOAuth2Dailymotion(params?: { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dailymotion>; /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dailymotion( - apiKey?: string, - apiSecret?: string, - enabled?: boolean, + apiKey?: string | null, + apiSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dailymotion>; updateOAuth2Dailymotion( paramsOrFirst?: - { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dailymotion> { - let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + let params: { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2195,15 +3531,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - apiKey: paramsOrFirst as string, - apiSecret: rest[0] as string, - enabled: rest[1] as boolean, + apiKey: paramsOrFirst as string | null, + apiSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2229,58 +3565,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Discord configuration. * - * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} */ updateOAuth2Discord(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }): Promise<Models.OAuth2Discord>; /** * Update the project OAuth2 Discord configuration. * - * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Discord( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2DiscordPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2DiscordPrompt[] | null, ): Promise<Models.OAuth2Discord>; updateOAuth2Discord( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2DiscordPrompt[] | null)?, + ] ): Promise<Models.OAuth2Discord> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; if ( @@ -2290,24 +3646,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2DiscordPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2316,12 +3672,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2330,48 +3686,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Disqus configuration. * - * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} */ updateOAuth2Disqus(params?: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Disqus>; /** * Update the project OAuth2 Disqus configuration. * - * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Disqus( - publicKey?: string, - secretKey?: string, - enabled?: boolean, + publicKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Disqus>; updateOAuth2Disqus( paramsOrFirst?: - | { publicKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Disqus> { let params: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -2381,15 +3758,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - publicKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + publicKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2415,44 +3792,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} */ updateOAuth2Dropbox(params?: { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dropbox>; /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dropbox( - appKey?: string, - appSecret?: string, - enabled?: boolean, + appKey?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dropbox>; updateOAuth2Dropbox( paramsOrFirst?: - { appKey?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dropbox> { - let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + let params: { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2461,15 +3863,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appKey: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appKey: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2495,48 +3897,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Etsy configuration. * - * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} */ updateOAuth2Etsy(params?: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Etsy>; /** * Update the project OAuth2 Etsy configuration. * - * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Etsy( - keyString?: string, - sharedSecret?: string, - enabled?: boolean, + keyString?: string | null, + sharedSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Etsy>; updateOAuth2Etsy( paramsOrFirst?: - | { keyString?: string; sharedSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Etsy> { let params: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2546,15 +3968,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - keyString: paramsOrFirst as string, - sharedSecret: rest[0] as string, - enabled: rest[1] as boolean, + keyString: paramsOrFirst as string | null, + sharedSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2580,44 +4002,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Facebook configuration. * - * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} */ updateOAuth2Facebook(params?: { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Facebook>; /** * Update the project OAuth2 Facebook configuration. * - * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Facebook( - appId?: string, - appSecret?: string, - enabled?: boolean, + appId?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Facebook>; updateOAuth2Facebook( paramsOrFirst?: - { appId?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Facebook> { - let params: { appId?: string; appSecret?: string; enabled?: boolean }; + let params: { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2626,15 +4073,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appId: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appId: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2660,48 +4107,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Figma configuration. * - * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} */ updateOAuth2Figma(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Figma>; /** * Update the project OAuth2 Figma configuration. * - * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Figma( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Figma>; updateOAuth2Figma( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Figma> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2711,15 +4178,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2745,58 +4212,74 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} */ updateOAuth2FusionAuth(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2FusionAuth>; /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2FusionAuth( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2FusionAuth>; updateOAuth2FusionAuth( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2FusionAuth> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -2806,17 +4289,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -2846,58 +4329,79 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 GitHub configuration. * - * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} */ updateOAuth2GitHub(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }): Promise<Models.OAuth2Github>; /** * Update the project OAuth2 GitHub configuration. * - * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2GitHub( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GitHubPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2GitHubPrompt[] | null, ): Promise<Models.OAuth2Github>; updateOAuth2GitHub( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2GitHubPrompt[] | null)?, + ] ): Promise<Models.OAuth2Github> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; if ( @@ -2907,24 +4411,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GitHubPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2933,12 +4437,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2947,58 +4451,75 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} */ updateOAuth2Gitlab(params?: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Gitlab>; /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Gitlab( - applicationId?: string, - secret?: string, - endpoint?: string, - enabled?: boolean, + applicationId?: string | null, + secret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Gitlab>; updateOAuth2Gitlab( paramsOrFirst?: | { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Gitlab> { let params: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -3008,17 +4529,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - applicationId: paramsOrFirst as string, - secret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + applicationId: paramsOrFirst as string | null, + secret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -3048,76 +4569,93 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Google configuration. * - * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} */ updateOAuth2Google(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Google>; /** * Update the project OAuth2 Google configuration. * - * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Google( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GooglePrompt[], - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + prompt?: ProjectOAuth2GooglePrompt[] | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Google>; updateOAuth2Google( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - ProjectOAuth2GooglePrompt[]?, - string[]?, - boolean?, - boolean?, + (string | null)?, + (ProjectOAuth2GooglePrompt[] | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Google> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -3127,29 +4665,29 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GooglePrompt[], - nativeClientIds: rest[2] as string[], - enabled: rest[3] as boolean, - nativeEnabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + prompt: rest[1] as ProjectOAuth2GooglePrompt[] | null, + enabled: rest[2] as boolean | null, + nativeClientIds: rest[3] as string[] | null, + nativeEnabled: rest[4] as boolean | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; @@ -3162,12 +4700,12 @@ export class Project { if (typeof prompt !== 'undefined') { apiPayload['prompt'] = prompt; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -3179,48 +4717,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Hugging Face configuration. * - * @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. + * @param {string | null} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} */ updateOAuth2HuggingFace(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2HuggingFace>; /** * 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. + * @param {string | null} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2HuggingFace( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2HuggingFace>; updateOAuth2HuggingFace( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2HuggingFace> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3230,15 +4791,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3264,58 +4825,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kakao configuration. * - * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} */ updateOAuth2Kakao(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }): Promise<Models.OAuth2Kakao>; /** * Update the project OAuth2 Kakao configuration. * - * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kakao( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2KakaoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2KakaoPrompt[] | null, ): Promise<Models.OAuth2Kakao>; updateOAuth2Kakao( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2KakaoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Kakao> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; if ( @@ -3325,24 +4906,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2KakaoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2KakaoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/kakao'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3351,12 +4932,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3365,64 +4946,86 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} */ updateOAuth2Keycloak(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Keycloak>; /** * Update the project OAuth2 Keycloak configuration. * - * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com - * @param {string} realmName - Keycloak realm name. For example: appwrite-realm - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Keycloak( - clientId?: string, - clientSecret?: string, - endpoint?: string, - realmName?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + realmName?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Keycloak>; updateOAuth2Keycloak( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Keycloak> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; if ( @@ -3432,19 +5035,19 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; } 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, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + realmName: rest[2] as string | null, + enabled: rest[3] as boolean | null, }; } @@ -3478,48 +5081,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kick configuration. * - * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} */ updateOAuth2Kick(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Kick>; /** * Update the project OAuth2 Kick configuration. * - * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kick( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Kick>; updateOAuth2Kick( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Kick> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3529,15 +5154,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3563,52 +5188,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} */ updateOAuth2Linkedin(params?: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Linkedin>; /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Linkedin( - clientId?: string, - primaryClientSecret?: string, - enabled?: boolean, + clientId?: string | null, + primaryClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Linkedin>; updateOAuth2Linkedin( paramsOrFirst?: | { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Linkedin> { let params: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3618,15 +5259,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + primaryClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3652,64 +5293,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} */ updateOAuth2Microsoft(params?: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }): Promise<Models.OAuth2Microsoft>; /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Microsoft( - applicationId?: string, - applicationSecret?: string, - tenant?: string, - prompt?: ProjectOAuth2MicrosoftPrompt[], - enabled?: boolean, + applicationId?: string | null, + applicationSecret?: string | null, + tenant?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2MicrosoftPrompt[] | null, ): Promise<Models.OAuth2Microsoft>; updateOAuth2Microsoft( paramsOrFirst?: | { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2MicrosoftPrompt[] | null)?, + ] ): Promise<Models.OAuth2Microsoft> { let params: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; if ( @@ -3719,27 +5381,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; } else { params = { - applicationId: paramsOrFirst as string, - applicationSecret: rest[0] as string, - tenant: rest[1] as string, - prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], - enabled: rest[3] as boolean, + applicationId: paramsOrFirst as string | null, + applicationSecret: rest[0] as string | null, + tenant: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[] | null, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3751,12 +5413,12 @@ export class Project { if (typeof tenant !== 'undefined') { apiPayload['tenant'] = tenant; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3765,52 +5427,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Notion configuration. * - * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} */ updateOAuth2Notion(params?: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Notion>; /** * Update the project OAuth2 Notion configuration. * - * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Notion( - oauthClientId?: string, - oauthClientSecret?: string, - enabled?: boolean, + oauthClientId?: string | null, + oauthClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Notion>; updateOAuth2Notion( paramsOrFirst?: | { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Notion> { let params: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3820,15 +5500,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauthClientId: paramsOrFirst as string, - oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauthClientId: paramsOrFirst as string | null, + oauthClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3854,97 +5534,113 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Oidc configuration. * - * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} */ updateOAuth2Oidc(params?: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Oidc>; /** * Update the project OAuth2 Oidc configuration. * - * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} * @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, + clientId?: string | null, + clientSecret?: string | null, + wellKnownURL?: string | null, + authorizationURL?: string | null, + tokenURL?: string | null, + userInfoURL?: string | null, + prompt?: ProjectOAuth2OidcPrompt[] | null, + maxAge?: number | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Oidc>; updateOAuth2Oidc( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - string?, - string?, - ProjectOAuth2OidcPrompt[]?, - number?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectOAuth2OidcPrompt[] | null)?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Oidc> { let params: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; if ( @@ -3954,27 +5650,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - wellKnownURL: rest[1] as string, - authorizationURL: rest[2] as string, - tokenURL: rest[3] as string, - userInfoURL: rest[4] as string, - prompt: rest[5] as ProjectOAuth2OidcPrompt[], - maxAge: rest[6] as number, - enabled: rest[7] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + wellKnownURL: rest[1] as string | null, + authorizationURL: rest[2] as string | null, + tokenURL: rest[3] as string | null, + userInfoURL: rest[4] as string | null, + prompt: rest[5] as ProjectOAuth2OidcPrompt[] | null, + maxAge: rest[6] as number | null, + enabled: rest[7] as boolean | null, }; } @@ -4024,76 +5720,97 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Okta configuration. * - * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} */ updateOAuth2Okta(params?: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }): Promise<Models.OAuth2Okta>; /** * Update the project OAuth2 Okta configuration. * - * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Okta( - clientId?: string, - clientSecret?: string, - domain?: string, - authorizationServerId?: string, - prompt?: ProjectOAuth2OktaPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + domain?: string | null, + authorizationServerId?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2OktaPrompt[] | null, ): Promise<Models.OAuth2Okta>; updateOAuth2Okta( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - ProjectOAuth2OktaPrompt[]?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2OktaPrompt[] | null)?, ] ): Promise<Models.OAuth2Okta> { let params: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; if ( @@ -4103,21 +5820,21 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - domain: rest[1] as string, - authorizationServerId: rest[2] as string, - prompt: rest[3] as ProjectOAuth2OktaPrompt[], - enabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + domain: rest[1] as string | null, + authorizationServerId: rest[2] as string | null, + enabled: rest[3] as boolean | null, + prompt: rest[4] as ProjectOAuth2OktaPrompt[] | null, }; } @@ -4125,8 +5842,8 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4141,12 +5858,12 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { apiPayload['authorizationServerId'] = authorizationServerId; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4155,48 +5872,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Paypal configuration. * - * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2Paypal(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 Paypal configuration. * - * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Paypal( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2Paypal( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4206,15 +5946,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4240,48 +5980,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2PaypalSandbox(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2PaypalSandbox( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2PaypalSandbox( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4291,15 +6051,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4325,48 +6085,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Podio configuration. * - * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} */ updateOAuth2Podio(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Podio>; /** * Update the project OAuth2 Podio configuration. * - * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Podio( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Podio>; updateOAuth2Podio( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Podio> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4376,15 +6156,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4410,48 +6190,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Resend configuration. * - * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} */ updateOAuth2Resend(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Resend>; /** * Update the project OAuth2 Resend configuration. * - * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Resend( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Resend>; updateOAuth2Resend( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Resend> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4461,15 +6261,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4495,58 +6295,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} */ updateOAuth2Salesforce(params?: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }): Promise<Models.OAuth2Salesforce>; /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Salesforce( - customerKey?: string, - customerSecret?: string, - prompt?: ProjectOAuth2SalesforcePrompt[], - enabled?: boolean, + customerKey?: string | null, + customerSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2SalesforcePrompt[] | null, ): Promise<Models.OAuth2Salesforce>; updateOAuth2Salesforce( paramsOrFirst?: | { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2SalesforcePrompt[] | null)?, + ] ): Promise<Models.OAuth2Salesforce> { let params: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; if ( @@ -4556,24 +6376,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; } else { params = { - customerKey: paramsOrFirst as string, - customerSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], - enabled: rest[2] as boolean, + customerKey: paramsOrFirst as string | null, + customerSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[] | null, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4582,12 +6402,12 @@ export class Project { if (typeof customerSecret !== 'undefined') { apiPayload['customerSecret'] = customerSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4596,48 +6416,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Slack configuration. * - * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} */ updateOAuth2Slack(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Slack>; /** * Update the project OAuth2 Slack configuration. * - * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Slack( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Slack>; updateOAuth2Slack( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Slack> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4647,15 +6488,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4681,48 +6522,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Spotify configuration. * - * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} */ updateOAuth2Spotify(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Spotify>; /** * Update the project OAuth2 Spotify configuration. * - * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Spotify( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Spotify>; updateOAuth2Spotify( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Spotify> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4732,15 +6593,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4766,48 +6627,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Stripe configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} */ updateOAuth2Stripe(params?: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Stripe>; /** * Update the project OAuth2 Stripe configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Stripe( - clientId?: string, - apiSecretKey?: string, - enabled?: boolean, + clientId?: string | null, + apiSecretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Stripe>; updateOAuth2Stripe( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Stripe> { let params: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4817,15 +6698,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + apiSecretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4851,48 +6732,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} */ updateOAuth2TikTok(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2TikTok>; /** * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TikTok( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2TikTok>; updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2TikTok> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4902,15 +6803,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4936,52 +6837,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2Tradeshift(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Tradeshift( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2Tradeshift( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4991,15 +6908,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5025,52 +6942,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2TradeshiftSandbox(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TradeshiftSandbox( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2TradeshiftSandbox( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5080,15 +7013,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5114,48 +7047,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Twitch configuration. * - * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} */ updateOAuth2Twitch(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Twitch>; /** * Update the project OAuth2 Twitch configuration. * - * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Twitch( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Twitch>; updateOAuth2Twitch( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Twitch> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5165,15 +7118,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5199,48 +7152,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Webflow configuration. * - * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} */ updateOAuth2Webflow(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Webflow>; /** * Update the project OAuth2 Webflow configuration. * - * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Webflow( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Webflow>; updateOAuth2Webflow( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Webflow> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5250,15 +7223,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5284,48 +7257,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 WordPress configuration. * - * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} */ updateOAuth2WordPress(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2WordPress>; /** * Update the project OAuth2 WordPress configuration. * - * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2WordPress( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2WordPress>; updateOAuth2WordPress( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2WordPress> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5335,15 +7328,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5369,48 +7362,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 X configuration. * - * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} */ updateOAuth2X(params?: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2X>; /** * Update the project OAuth2 X configuration. * - * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2X( - customerKey?: string, - secretKey?: string, - enabled?: boolean, + customerKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2X>; updateOAuth2X( paramsOrFirst?: - | { customerKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2X> { let params: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -5420,15 +7433,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - customerKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + customerKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5454,48 +7467,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} */ updateOAuth2Yahoo(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yahoo>; /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yahoo( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yahoo>; updateOAuth2Yahoo( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yahoo> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5505,15 +7538,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5539,48 +7572,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yandex configuration. * - * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} */ updateOAuth2Yandex(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yandex>; /** * Update the project OAuth2 Yandex configuration. * - * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yandex( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yandex>; updateOAuth2Yandex( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yandex> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5590,15 +7643,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5624,58 +7677,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoho configuration. * - * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} */ updateOAuth2Zoho(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }): Promise<Models.OAuth2Zoho>; /** * Update the project OAuth2 Zoho configuration. * - * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoho( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2ZohoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2ZohoPrompt[] | null, ): Promise<Models.OAuth2Zoho>; updateOAuth2Zoho( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2ZohoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Zoho> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; if ( @@ -5685,24 +7758,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2ZohoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5711,12 +7784,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5725,48 +7798,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoom configuration. * - * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} */ updateOAuth2Zoom(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Zoom>; /** * Update the project OAuth2 Zoom configuration. * - * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoom( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Zoom>; updateOAuth2Zoom( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Zoom> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5776,15 +7870,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5810,7 +7904,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +8191,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + platforms: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +8213,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6098,6 +8221,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise<Models.PlatformAndroid>; /** * 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. @@ -6105,6 +8229,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +8238,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise<Models.PlatformAndroid>; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +8267,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +8306,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +8317,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6191,13 +8351,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }): Promise<Models.PlatformAndroid>; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +8368,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[] | null, ): Promise<Models.PlatformAndroid>; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + }; if ( paramsOrFirst && @@ -6224,18 +8397,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[] | null, }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +8436,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +8447,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +8561,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +8674,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +8782,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +8890,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8998,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +9106,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +9223,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +9340,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +9557,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + policies: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +9628,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +9760,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +9892,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +10024,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +10223,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +10398,209 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise<Models.Project>; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise<Models.Project>; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise<Models.Project> { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +10658,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7757,38 +10740,38 @@ export class Project { * * 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. + * @param {number | null} 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<Models.Project>} */ updatePasswordHistoryPolicy(params: { - total?: number; + total?: number | null; }): Promise<Models.Project>; /** * 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. + * @param {number | null} 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<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy(total?: number | null): Promise<Models.Project>; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -7809,7 +10792,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +10924,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +11079,224 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise<Models.Project>; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise<Models.Project>; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise<Models.Project> { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +11409,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +11484,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +11616,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +11748,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,40 +11878,116 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ - updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + updateUserLimitPolicy(params: { + total?: number | null; + }): Promise<Models.Project>; /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy(total?: number | null): Promise<Models.Project>; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -8345,15 +12008,89 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +12100,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +12112,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +12130,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +12142,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +12152,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +12164,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +12280,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,104 +12435,179 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * - * @param {string} params.host - SMTP server hostname (domain) - * @param {number} params.port - SMTP server port - * @param {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} params.host - SMTP server hostname (domain) + * @param {number | null} params.port - SMTP server port + * @param {string | null} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ updateSMTP(params?: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }): Promise<Models.Project>; /** * 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. * - * @param {string} host - SMTP server hostname (domain) - * @param {number} port - SMTP server port - * @param {string} username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} host - SMTP server hostname (domain) + * @param {number | null} port - SMTP server port + * @param {string | null} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @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, + host?: string | null, + port?: number | null, + username?: string | null, + password?: string | null, + senderEmail?: string | null, + senderName?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, + secure?: ProjectSMTPSecure | null, + enabled?: boolean | null, ): Promise<Models.Project>; updateSMTP( paramsOrFirst?: | { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - number?, - string?, - string?, - string?, - string?, - string?, - string?, - ProjectSMTPSecure?, - boolean?, + (number | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectSMTPSecure | null)?, + (boolean | null)?, ] ): Promise<Models.Project> { let params: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; if ( @@ -8725,29 +12617,29 @@ export class Project { !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; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; } else { params = { - host: paramsOrFirst as string, - port: rest[0] as number, - username: rest[1] as string, - password: rest[2] as string, - senderEmail: rest[3] as string, - senderName: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, - secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean, + host: paramsOrFirst as string | null, + port: rest[0] as number | null, + username: rest[1] as string | null, + password: rest[2] as string | null, + senderEmail: rest[3] as string | null, + senderName: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, + secure: rest[7] as ProjectSMTPSecure | null, + enabled: rest[8] as boolean | null, }; } @@ -8801,7 +12693,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +12889,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + templates: [], + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8931,36 +12927,36 @@ export class Project { * * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. - * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} params.senderName - Name of the email sender. - * @param {string} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Reply to name. + * @param {string | null} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} params.senderName - Name of the email sender. + * @param {string | null} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} */ updateEmailTemplate(params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.EmailTemplate>; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} subject - Subject of the email template. Can be up to 255 characters. - * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} senderName - Name of the email sender. - * @param {string} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Reply to name. + * @param {string | null} subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} senderName - Name of the email sender. + * @param {string | null} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8968,45 +12964,45 @@ export class Project { updateEmailTemplate( templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, - subject?: string, - message?: string, - senderName?: string, - senderEmail?: string, - replyToEmail?: string, - replyToName?: string, + subject?: string | null, + message?: string | null, + senderName?: string | null, + senderEmail?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.EmailTemplate>; updateEmailTemplate( paramsOrFirst: | { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; } | ProjectEmailTemplateId, ...rest: [ ProjectEmailTemplateLocale?, - string?, - string?, - string?, - string?, - string?, - string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.EmailTemplate> { let params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -9025,23 +13021,23 @@ export class Project { params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, locale: rest[0] as ProjectEmailTemplateLocale, - subject: rest[1] as string, - message: rest[2] as string, - senderName: rest[3] as string, - senderEmail: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, + subject: rest[1] as string | null, + message: rest[2] as string | null, + senderName: rest[3] as string | null, + senderEmail: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, }; } @@ -9092,7 +13088,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +13188,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +13275,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +13416,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,58 +13490,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ updateVariable( variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.Variable> { let params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -9468,16 +13570,16 @@ export class Project { ) { params = (paramsOrFirst || {}) as { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } else { params = { variableId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean, + key: rest[0] as string | null, + value: rest[1] as string | null, + secret: rest[2] as boolean | null, }; } @@ -9512,7 +13614,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..162a7bf 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,13 +111,28 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -124,7 +144,7 @@ export class Proxy { /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -174,7 +194,43 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + rules: [], + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +288,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +404,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +566,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +680,144 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} params.domain - Domain that receives email. + * @param {string} params.functionId - ID of function to execute. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createSMTPRule(params: { + domain: string; + functionId: string; + branch?: string; + }): Promise<Models.ProxyRule>; + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} domain - Domain that receives email. + * @param {string} functionId - ID of function to execute. + * @param {string} branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSMTPRule( + domain: string, + functionId: string, + branch?: string, + ): Promise<Models.ProxyRule>; + createSMTPRule( + paramsOrFirst: + { domain: string; functionId: string; branch?: string } | string, + ...rest: [string?, string?] + ): Promise<Models.ProxyRule> { + 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, + }; + } + + 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"', + ); + } + const apiPath = '/proxy/rules/smtp'; + const apiPayload: Payload = {}; + if (typeof domain !== 'undefined') { + apiPayload['domain'] = domain; + } + if (typeof functionId !== 'undefined') { + apiPayload['functionId'] = functionId; + } + if (typeof branch !== 'undefined') { + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +870,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +1001,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2424cc0 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,79 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + sites: [], + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +550,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +662,47 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + frameworks: [], + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + runtimes: [], + adapters: [], + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +770,33 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +847,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -667,16 +928,16 @@ export class Sites { * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} */ @@ -695,16 +956,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }): Promise<Models.Site>; /** * Update site by its unique ID. @@ -723,16 +984,16 @@ export class Sites { * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} * @deprecated Use the object parameter style method for a better developer experience. @@ -752,16 +1013,16 @@ export class Sites { adapter?: Adapter, fallbackFile?: string, installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, runtimeSpecification?: string, deploymentRetention?: number, - scopes?: ProjectKeyScopes[], + scopes?: ProjectKeyScopes[] | null, ): Promise<Models.Site>; update( paramsOrFirst: @@ -780,16 +1041,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; } | string, ...rest: [ @@ -806,16 +1067,16 @@ export class Sites { Adapter?, string?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, string?, number?, - ProjectKeyScopes[]?, + (ProjectKeyScopes[] | null)?, ] ): Promise<Models.Site> { let params: { @@ -833,16 +1094,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; if ( @@ -865,16 +1126,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; } else { params = { @@ -892,16 +1153,16 @@ export class Sites { adapter: rest[10] as Adapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, - providerRepositoryId: rest[13] as string, + providerRepositoryId: rest[13] as string | null, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - providerBranches: rest[17] as string[], - providerPaths: rest[18] as string[], - buildSpecification: rest[19] as string, + providerBranches: rest[17] as string[] | null, + providerPaths: rest[18] as string[] | null, + buildSpecification: rest[19] as string | null, runtimeSpecification: rest[20] as string, deploymentRetention: rest[21] as number, - scopes: rest[22] as ProjectKeyScopes[], + scopes: rest[22] as ProjectKeyScopes[] | null, }; } @@ -1022,7 +1283,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1472,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1635,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1910,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2118,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2270,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2381,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2677,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2795,59 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2910,48 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3093,37 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3249,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3336,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2586,27 +3363,27 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2614,28 +3391,33 @@ export class Sites { updateVariable( siteId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2646,17 +3428,17 @@ export class Sites { params = (paramsOrFirst || {}) as { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2694,7 +3476,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..d810652 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,43 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + buckets: [], + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -101,7 +138,7 @@ export class Storage { * * @param {string} params.bucketId - 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 - Bucket name - * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -116,7 +153,7 @@ export class Storage { createBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -131,7 +168,7 @@ export class Storage { * * @param {string} bucketId - 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 - Bucket name - * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -147,7 +184,7 @@ export class Storage { createBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, @@ -162,7 +199,7 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -175,7 +212,7 @@ export class Storage { | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, number?, @@ -189,7 +226,7 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -208,7 +245,7 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -222,7 +259,7 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, maximumFileSize: rest[4] as number, @@ -296,7 +333,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +413,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,13 +446,13 @@ export class Storage { * * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.name - Bucket name - * @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 {string[] | null} 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.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -374,13 +461,13 @@ export class Storage { updateBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }): Promise<Models.Bucket>; @@ -389,13 +476,13 @@ export class Storage { * * @param {string} bucketId - Bucket unique ID. * @param {string} name - Bucket name - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -405,13 +492,13 @@ export class Storage { updateBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, - maximumFileSize?: number, + maximumFileSize?: number | null, allowedFileExtensions?: string[], - compression?: Compression, - encryption?: boolean, + compression?: Compression | null, + encryption?: boolean | null, antivirus?: boolean, transformations?: boolean, ): Promise<Models.Bucket>; @@ -420,26 +507,26 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; } | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, - number?, + (number | null)?, string[]?, - Compression?, - boolean?, + (Compression | null)?, + (boolean | null)?, boolean?, boolean?, ] @@ -447,13 +534,13 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -466,13 +553,13 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -480,13 +567,13 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, - maximumFileSize: rest[4] as number, + maximumFileSize: rest[4] as number | null, allowedFileExtensions: rest[5] as string[], - compression: rest[6] as Compression, - encryption: rest[7] as boolean, + compression: rest[6] as Compression | null, + encryption: rest[7] as boolean | null, antivirus: rest[8] as boolean, transformations: rest[9] as boolean, }; @@ -554,7 +641,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +824,45 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + files: [], + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1084,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -943,7 +1120,7 @@ export class Storage { * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.fileId - File ID. * @param {string} params.name - File name. - * @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 {string[] | null} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ @@ -951,7 +1128,7 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }): Promise<Models.File>; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -959,7 +1136,7 @@ export class Storage { * @param {string} bucketId - Bucket unique ID. * @param {string} fileId - File ID. * @param {string} name - File name. - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} * @deprecated Use the object parameter style method for a better developer experience. @@ -968,7 +1145,7 @@ export class Storage { bucketId: string, fileId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, ): Promise<Models.File>; updateFile( paramsOrFirst: @@ -976,16 +1153,16 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.File> { let params: { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; if ( @@ -997,14 +1174,14 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; } 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[] | null, }; } @@ -1038,7 +1215,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..adb947d 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,69 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,7 +167,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -110,7 +177,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -121,7 +188,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -132,7 +199,7 @@ export class TablesDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -142,10 +209,10 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -153,7 +220,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -167,7 +234,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -176,7 +243,7 @@ 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 | null, }; } @@ -222,7 +289,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +359,42 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +462,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +542,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +616,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +722,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +870,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +942,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,9 +1002,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -712,9 +1012,9 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -722,9 +1022,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -733,9 +1033,9 @@ export class TablesDB { databaseId: string, name?: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -743,20 +1043,26 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -768,18 +1074,18 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -822,7 +1128,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,33 +1240,33 @@ export class TablesDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -918,12 +1275,12 @@ export class TablesDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -950,7 +1307,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,11 +1420,50 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + migrations: [], + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} params.databaseId - Database ID. * @param {string} params.specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1025,7 +1477,7 @@ export class TablesDB { autoCutover?: boolean; }): Promise<Models.DatabaseMigration>; /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} databaseId - Database ID. * @param {string} specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1105,7 +1557,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1658,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1253,7 +1761,7 @@ export class TablesDB { } /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} params.databaseId - Database ID. * @param {string} params.migrationId - Migration ID. @@ -1265,7 +1773,7 @@ export class TablesDB { migrationId: string; }): Promise<Models.DatabaseMigration>; /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} databaseId - Database ID. * @param {string} migrationId - Migration ID. @@ -1327,7 +1835,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1967,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2054,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2138,52 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2287,59 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + tables: [], + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1656,11 +2348,11 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - 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 - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} params.columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} */ @@ -1668,7 +2360,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1680,11 +2372,11 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - 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 - Table 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 {string[] | null} 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} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1693,7 +2385,7 @@ export class TablesDB { databaseId: string, tableId: string, name: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, columns?: object[], @@ -1705,7 +2397,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1715,7 +2407,7 @@ export class TablesDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1726,7 +2418,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1742,7 +2434,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1753,7 +2445,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], @@ -1816,7 +2508,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2619,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1895,7 +2669,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.name - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1906,7 +2680,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1917,7 +2691,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} name - Table 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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1929,7 +2703,7 @@ export class TablesDB { databaseId: string, tableId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1940,19 +2714,26 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Table> { let params: { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1967,7 +2748,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1977,7 +2758,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -2028,7 +2809,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +3023,20 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + columns: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2212,9 +3047,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2224,9 +3059,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnBigint>; /** @@ -2237,9 +3072,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2250,9 +3085,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnBigint>; createBigIntColumn( @@ -2262,9 +3097,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -2272,9 +3107,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnBigint> { @@ -2283,9 +3118,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -2299,9 +3134,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -2310,9 +3145,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -2373,7 +3208,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,10 +3236,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} */ @@ -2396,10 +3248,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnBigint>; /** * Update a bigint column. Changing the `default` value will not update already existing rows. @@ -2409,10 +3261,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2422,10 +3274,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnBigint>; updateBigIntColumn( paramsOrFirst: @@ -2434,20 +3286,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnBigint> { let params: { @@ -2455,10 +3307,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -2471,10 +3323,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -2482,10 +3334,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -2549,7 +3401,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2560,7 +3429,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2570,7 +3439,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.ColumnBoolean>; /** @@ -2581,7 +3450,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2592,7 +3461,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.ColumnBoolean>; createBooleanColumn( @@ -2602,18 +3471,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -2627,7 +3496,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -2636,7 +3505,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -2690,7 +3559,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2700,8 +3586,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} */ @@ -2710,8 +3596,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.ColumnBoolean>; /** * Update a boolean column. Changing the `default` value will not update already existing rows. @@ -2720,8 +3606,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2731,8 +3617,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.ColumnBoolean>; updateBooleanColumn( paramsOrFirst: @@ -2741,19 +3627,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2766,8 +3658,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2775,8 +3667,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2832,7 +3724,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2842,7 +3751,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2852,7 +3761,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnDatetime>; /** @@ -2862,7 +3771,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2873,7 +3782,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnDatetime>; createDatetimeColumn( @@ -2883,18 +3792,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2908,7 +3817,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2917,7 +3826,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2971,7 +3880,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2981,8 +3907,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} */ @@ -2991,8 +3917,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnDatetime>; /** * Update a date time column. Changing the `default` value will not update already existing rows. @@ -3001,8 +3927,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3012,8 +3938,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnDatetime>; updateDatetimeColumn( paramsOrFirst: @@ -3022,19 +3948,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3047,8 +3979,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3056,8 +3988,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3113,7 +4045,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3124,7 +4073,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3134,7 +4083,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEmail>; /** @@ -3145,7 +4094,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3156,7 +4105,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEmail>; createEmailColumn( @@ -3166,18 +4115,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3191,7 +4140,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3200,7 +4149,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3253,7 +4202,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,8 +4231,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} */ @@ -3274,8 +4241,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEmail>; /** * Update an email column. Changing the `default` value will not update already existing rows. @@ -3285,8 +4252,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3296,8 +4263,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEmail>; updateEmailColumn( paramsOrFirst: @@ -3306,19 +4273,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3331,8 +4304,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3340,8 +4313,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3397,7 +4370,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3408,7 +4399,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3419,7 +4410,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEnum>; /** @@ -3430,7 +4421,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3442,7 +4433,7 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEnum>; createEnumColumn( @@ -3453,11 +4444,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3465,7 +4463,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3480,7 +4478,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3490,7 +4488,7 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -3552,7 +4550,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3564,8 +4581,8 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} */ @@ -3575,8 +4592,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEnum>; /** * Update an enum column. Changing the `default` value will not update already existing rows. @@ -3587,8 +4604,8 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3599,8 +4616,8 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEnum>; updateEnumColumn( paramsOrFirst: @@ -3610,11 +4627,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3622,8 +4646,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3637,8 +4661,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3647,8 +4671,8 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3713,7 +4737,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3724,9 +4767,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3736,9 +4779,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.ColumnFloat>; /** @@ -3749,9 +4792,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3762,9 +4805,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.ColumnFloat>; createFloatColumn( @@ -3774,9 +4817,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3784,9 +4827,9 @@ export class TablesDB { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.ColumnFloat> { @@ -3795,9 +4838,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3811,9 +4854,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3822,9 +4865,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3885,7 +4928,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3896,10 +4956,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} */ @@ -3908,10 +4968,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.ColumnFloat>; /** * Update a float column. Changing the `default` value will not update already existing rows. @@ -3921,10 +4981,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3934,10 +4994,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.ColumnFloat>; updateFloatColumn( paramsOrFirst: @@ -3946,20 +5006,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.ColumnFloat> { let params: { @@ -3967,10 +5027,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3983,10 +5043,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3994,10 +5054,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -4061,7 +5121,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4072,9 +5149,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4084,9 +5161,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnInteger>; /** @@ -4097,9 +5174,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4110,9 +5187,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnInteger>; createIntegerColumn( @@ -4122,9 +5199,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -4132,9 +5209,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnInteger> { @@ -4143,9 +5220,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -4159,9 +5236,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -4170,9 +5247,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -4234,7 +5311,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4245,10 +5339,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} */ @@ -4257,10 +5351,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnInteger>; /** * Update an integer column. Changing the `default` value will not update already existing rows. @@ -4270,10 +5364,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4283,10 +5377,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnInteger>; updateIntegerColumn( paramsOrFirst: @@ -4295,20 +5389,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnInteger> { let params: { @@ -4316,10 +5410,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -4332,10 +5426,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -4343,10 +5437,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -4410,7 +5504,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4421,7 +5532,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4431,7 +5542,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnIp>; /** @@ -4442,7 +5553,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4453,7 +5564,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnIp>; createIpColumn( @@ -4463,18 +5574,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -4488,7 +5599,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -4497,7 +5608,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -4550,7 +5661,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4561,8 +5690,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} */ @@ -4571,8 +5700,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnIp>; /** * Update an ip column. Changing the `default` value will not update already existing rows. @@ -4582,8 +5711,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4593,8 +5722,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnIp>; updateIpColumn( paramsOrFirst: @@ -4603,19 +5732,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4628,8 +5763,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4637,8 +5772,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4694,7 +5829,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4704,7 +5857,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4713,7 +5866,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnLine>; /** * Create a geometric line column. @@ -4722,7 +5875,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4732,7 +5885,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnLine>; createLineColumn( paramsOrFirst: @@ -4741,17 +5894,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4764,7 +5917,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4772,7 +5925,7 @@ export class TablesDB { 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[][] | null, }; } @@ -4820,7 +5973,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4830,8 +6000,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4840,8 +6010,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnLine>; /** * Update a line column. Changing the `default` value will not update already existing rows. @@ -4850,8 +6020,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4861,8 +6031,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnLine>; updateLineColumn( paramsOrFirst: @@ -4871,19 +6041,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4896,8 +6072,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4905,8 +6081,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4957,7 +6133,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4968,7 +6161,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -4979,7 +6172,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnLongtext>; @@ -4991,7 +6184,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5003,7 +6196,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnLongtext>; @@ -5014,19 +6207,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5041,7 +6241,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5051,7 +6251,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5110,7 +6310,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5121,8 +6338,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} */ @@ -5131,8 +6348,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnLongtext>; /** * Update a longtext column. Changing the `default` value will not update already existing rows. @@ -5142,8 +6359,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5153,8 +6370,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnLongtext>; updateLongtextColumn( paramsOrFirst: @@ -5163,19 +6380,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5188,8 +6411,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5197,8 +6420,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5254,7 +6477,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5265,7 +6505,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5276,7 +6516,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnMediumtext>; @@ -5288,7 +6528,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5300,7 +6540,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnMediumtext>; @@ -5311,19 +6551,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5338,7 +6585,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5348,7 +6595,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5407,7 +6654,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5418,8 +6682,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} */ @@ -5428,8 +6692,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnMediumtext>; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -5439,8 +6703,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5450,8 +6714,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnMediumtext>; updateMediumtextColumn( paramsOrFirst: @@ -5460,19 +6724,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5485,8 +6755,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5494,8 +6764,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5551,7 +6821,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5561,7 +6848,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5570,7 +6857,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.ColumnPoint>; /** * Create a geometric point column. @@ -5579,7 +6866,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5589,7 +6876,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.ColumnPoint>; createPointColumn( paramsOrFirst: @@ -5598,17 +6885,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -5621,7 +6908,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -5629,7 +6916,7 @@ export class TablesDB { 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[] | null, }; } @@ -5677,7 +6964,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5687,8 +6991,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5697,8 +7001,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.ColumnPoint>; /** * Update a point column. Changing the `default` value will not update already existing rows. @@ -5707,8 +7011,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5718,8 +7022,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.ColumnPoint>; updatePointColumn( paramsOrFirst: @@ -5728,19 +7032,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5753,8 +7063,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5762,8 +7072,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5814,7 +7124,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5824,7 +7151,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5833,7 +7160,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnPolygon>; /** * Create a geometric polygon column. @@ -5842,7 +7169,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5852,7 +7179,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnPolygon>; createPolygonColumn( paramsOrFirst: @@ -5861,17 +7188,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5884,7 +7211,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5892,7 +7219,7 @@ export class TablesDB { 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[][] | null, }; } @@ -5941,7 +7268,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5951,8 +7295,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5961,8 +7305,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnPolygon>; /** * Update a polygon column. Changing the `default` value will not update already existing rows. @@ -5971,8 +7315,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5982,8 +7326,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnPolygon>; updatePolygonColumn( paramsOrFirst: @@ -5992,19 +7336,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -6017,8 +7367,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -6026,8 +7376,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -6078,7 +7428,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6090,8 +7457,8 @@ export class TablesDB { * @param {string} params.relatedTableId - Related Table ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Column Key. - * @param {string} params.twoWayKey - Two Way Column Key. + * @param {string | null} params.key - Column Key. + * @param {string | null} params.twoWayKey - Two Way Column Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6102,8 +7469,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.ColumnRelationship>; /** @@ -6115,8 +7482,8 @@ export class TablesDB { * @param {string} relatedTableId - Related Table ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Column Key. - * @param {string} twoWayKey - Two Way Column Key. + * @param {string | null} key - Column Key. + * @param {string | null} twoWayKey - Two Way Column Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6128,8 +7495,8 @@ export class TablesDB { relatedTableId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.ColumnRelationship>; createRelationshipColumn( @@ -6140,8 +7507,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -6150,8 +7517,8 @@ export class TablesDB { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.ColumnRelationship> { @@ -6161,8 +7528,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -6177,8 +7544,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -6188,8 +7555,8 @@ export class TablesDB { relatedTableId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -6251,7 +7618,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6261,8 +7650,8 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. + * @param {RelationMutate | null} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} */ @@ -6270,8 +7659,8 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }): Promise<Models.ColumnRelationship>; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -6280,8 +7669,8 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. + * @param {RelationMutate | null} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6290,8 +7679,8 @@ export class TablesDB { databaseId: string, tableId: string, key: string, - onDelete?: RelationMutate, - newKey?: string, + onDelete?: RelationMutate | null, + newKey?: string | null, ): Promise<Models.ColumnRelationship>; updateRelationshipColumn( paramsOrFirst: @@ -6299,18 +7688,18 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, (RelationMutate | null)?, (string | null)?] ): Promise<Models.ColumnRelationship> { let params: { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; if ( @@ -6322,16 +7711,16 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; } 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, + onDelete: rest[2] as RelationMutate | null, + newKey: rest[3] as string | null, }; } @@ -6373,7 +7762,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6385,7 +7796,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6398,7 +7809,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnString>; @@ -6411,7 +7822,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6424,7 +7835,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnString>; @@ -6436,7 +7847,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6446,7 +7857,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6457,7 +7868,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6473,7 +7884,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6484,7 +7895,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6549,7 +7960,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6560,9 +7989,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the string column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the string column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6572,9 +8001,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnString>; /** * Update a string column. Changing the `default` value will not update already existing rows. @@ -6584,9 +8013,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the string column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the string column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6596,9 +8025,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnString>; updateStringColumn( paramsOrFirst: @@ -6607,21 +8036,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnString> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6634,9 +8070,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6644,9 +8080,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6706,7 +8142,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6717,7 +8171,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6728,7 +8182,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnText>; @@ -6740,7 +8194,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6752,7 +8206,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnText>; @@ -6763,19 +8217,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6790,7 +8251,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6800,7 +8261,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6858,7 +8319,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6869,8 +8347,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} */ @@ -6879,8 +8357,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnText>; /** * Update a text column. Changing the `default` value will not update already existing rows. @@ -6890,8 +8368,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6901,8 +8379,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnText>; updateTextColumn( paramsOrFirst: @@ -6911,19 +8389,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6936,8 +8420,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6945,8 +8429,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7002,7 +8486,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7013,7 +8514,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7023,7 +8524,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnUrl>; /** @@ -7034,7 +8535,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7045,7 +8546,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnUrl>; createUrlColumn( @@ -7055,18 +8556,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -7080,7 +8581,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -7089,7 +8590,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -7142,7 +8643,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7153,8 +8672,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} */ @@ -7163,8 +8682,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnUrl>; /** * Update an url column. Changing the `default` value will not update already existing rows. @@ -7174,8 +8693,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7185,8 +8704,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnUrl>; updateUrlColumn( paramsOrFirst: @@ -7195,19 +8714,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -7220,8 +8745,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -7229,8 +8754,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7286,7 +8811,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7298,7 +8841,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7310,7 +8853,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnVarchar>; @@ -7323,7 +8866,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7336,7 +8879,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnVarchar>; @@ -7348,7 +8891,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -7358,7 +8901,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -7369,7 +8912,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7385,7 +8928,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7396,7 +8939,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -7462,7 +9005,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7473,9 +9034,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the varchar column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the varchar column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} */ @@ -7484,9 +9045,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnVarchar>; /** * Update a varchar column. Changing the `default` value will not update already existing rows. @@ -7496,9 +9057,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the varchar column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the varchar column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7508,9 +9069,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnVarchar>; updateVarcharColumn( paramsOrFirst: @@ -7519,21 +9080,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnVarchar> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -7546,9 +9114,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -7556,9 +9124,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7618,7 +9186,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,12 +9533,43 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -7975,7 +9592,7 @@ export class TablesDB { }): Promise<Models.ColumnIndex>; /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -8109,7 +9726,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9831,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +10062,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8415,8 +10101,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -8427,8 +10113,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -8437,8 +10123,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8450,8 +10136,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8462,8 +10148,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8472,8 +10158,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -8483,8 +10169,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8499,8 +10185,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8510,8 +10196,8 @@ export class TablesDB { data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8561,7 +10247,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8570,7 +10274,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} params.rows - Array of rows data as JSON objects. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8578,7 +10282,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8586,7 +10290,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} rows - Array of rows data as JSON objects. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8595,7 +10299,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; createRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8603,16 +10307,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8624,14 +10328,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8670,7 +10374,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8680,7 +10413,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8688,7 +10421,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8697,7 +10430,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8706,7 +10439,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; upsertRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8714,16 +10447,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8735,14 +10468,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8781,7 +10514,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8791,7 +10553,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column 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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8800,7 +10562,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8809,7 +10571,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column 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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8819,7 +10581,7 @@ export class TablesDB { tableId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; updateRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8828,17 +10590,17 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8851,7 +10613,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -8859,7 +10621,7 @@ export class TablesDB { 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 | null, }; } @@ -8899,7 +10661,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10796,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10943,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9133,8 +10971,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9145,8 +10983,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -9155,8 +10993,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9168,8 +11006,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; upsertRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9181,8 +11019,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9191,8 +11029,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9202,8 +11040,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9219,8 +11057,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9231,8 +11069,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9277,7 +11115,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9287,8 +11143,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9299,8 +11155,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -9309,8 +11165,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9322,8 +11178,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; updateRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9335,8 +11191,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9345,8 +11201,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9356,8 +11212,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9373,8 +11229,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9385,8 +11241,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9431,7 +11287,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9549,8 +11423,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9560,8 +11434,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Decrement a specific column of a row by a given value. @@ -9571,8 +11445,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9583,8 +11457,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Row>; decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9594,11 +11468,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9606,8 +11487,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -9621,8 +11502,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9631,8 +11512,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9683,7 +11564,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9694,8 +11593,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9705,8 +11604,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Increment a specific column of a row by a given value. @@ -9716,8 +11615,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9728,8 +11627,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Row>; incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9739,11 +11638,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9751,8 +11657,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -9766,8 +11672,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9776,8 +11682,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9828,6 +11734,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..8e9f2ae 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,34 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + teams: [], + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +205,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +278,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +368,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +517,38 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +638,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +732,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,21 +760,21 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} teamId - Team ID. * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. @@ -631,22 +782,22 @@ export class Teams { updateInstallation( teamId: string, installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: | { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.AppInstallation> { let params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; if ( @@ -657,13 +808,13 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string, + authorizationDetails: rest[1] as string | null, }; } @@ -696,7 +847,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1041,44 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -890,6 +1098,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} */ @@ -901,6 +1110,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise<Models.Membership>; /** * 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. @@ -919,6 +1129,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} * @deprecated Use the object parameter style method for a better developer experience. @@ -931,6 +1142,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise<Models.Membership>; createMembership( paramsOrFirst: @@ -942,9 +1154,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise<Models.Membership> { let params: { teamId: string; @@ -954,6 +1175,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -969,6 +1191,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -979,6 +1202,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -989,6 +1213,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1018,6 +1243,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1026,7 +1254,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1354,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1471,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1688,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..580a3d4 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,36 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -116,21 +150,21 @@ export class Tokens { * * @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 unique ID. - * @param {string} params.expire - Token expiry date + * @param {string | null} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ createFileToken(params: { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * * @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 unique ID. - * @param {string} expire - Token expiry date + * @param {string | null} expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. @@ -138,14 +172,19 @@ export class Tokens { createFileToken( bucketId: string, fileId: string, - expire?: string, + expire?: string | null, ): Promise<Models.ResourceToken>; createFileToken( paramsOrFirst: - { bucketId: string; fileId: string; expire?: string } | string, - ...rest: [string?, string?] + | { bucketId: string; fileId: string; expire?: string | null } + | string, + ...rest: [string?, (string | null)?] ): Promise<Models.ResourceToken> { - let params: { bucketId: string; fileId: string; expire?: string }; + let params: { + bucketId: string; + fileId: string; + expire?: string | null; + }; if ( paramsOrFirst && @@ -155,13 +194,13 @@ export class Tokens { params = (paramsOrFirst || {}) as { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string, + expire: rest[1] as string | null, }; } @@ -191,7 +230,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,36 +303,57 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} params.tokenId - Token unique ID. - * @param {string} params.expire - File token expiry date + * @param {string | null} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ update(params: { tokenId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} tokenId - Token unique ID. - * @param {string} expire - File token expiry date + * @param {string | null} expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; update( - paramsOrFirst: { tokenId: string; expire?: string } | string, - ...rest: [string?] + tokenId: string, + expire?: string | null, + ): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string; expire?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.ResourceToken> { - let params: { tokenId: string; expire?: string }; + let params: { tokenId: string; expire?: string | null }; if ( paramsOrFirst && @@ -284,12 +362,12 @@ export class Tokens { ) { params = (paramsOrFirst || {}) as { tokenId: string; - expire?: string; + expire?: string | null; }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string, + expire: rest[0] as string | null, }; } @@ -316,7 +394,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..77a515b 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,16 +94,70 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + users: [], + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new user. * * @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. - * @param {string} params.email - User email. - * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string | null} params.email - User email. + * @param {string | null} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} params.password - Plain text user password. Must be at least 8 chars. * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -107,18 +166,18 @@ export class Users { Preferences extends Models.Preferences = Models.DefaultPreferences, >(params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }): Promise<Models.User<Preferences>>; /** * Create a new user. * * @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. - * @param {string} email - User email. - * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string | null} email - User email. + * @param {string | null} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} password - Plain text user password. Must be at least 8 chars. * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -126,28 +185,28 @@ export class Users { */ create<Preferences extends Models.Preferences = Models.DefaultPreferences>( userId: string, - email?: string, - phone?: string, - password?: string, + email?: string | null, + phone?: string | null, + password?: string | null, name?: string, ): Promise<Models.User<Preferences>>; create<Preferences extends Models.Preferences = Models.DefaultPreferences>( paramsOrFirst: | { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [(string | null)?, (string | null)?, (string | null)?, string?] ): Promise<Models.User<Preferences>> { let params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; @@ -158,17 +217,17 @@ export class Users { ) { params = (paramsOrFirst || {}) as { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string, - phone: rest[1] as string, - password: rest[2] as string, + email: rest[0] as string | null, + phone: rest[1] as string | null, + password: rest[2] as string | null, name: rest[3] as string, }; } @@ -206,7 +265,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +420,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +575,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +697,40 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +898,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1053,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1307,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1518,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1690,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1790,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1959,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2083,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2301,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2446,44 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2558,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2675,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2930,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +3000,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3069,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3141,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3277,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3345,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3414,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3482,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3568,410 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise<Models.PasskeyList> { + 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, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise<Models.Passkey>; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4050,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4170,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4408,58 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4517,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4752,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4876,37 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5048,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5135,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5270,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5439,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5538,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5663,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..d2f0c5d 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,69 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class VectorsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class VectorsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class VectorsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,59 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1530,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1647,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1209,7 +1700,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} */ @@ -1220,7 +1711,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.VectorsdbCollection>; /** * Update a collection by its unique ID. @@ -1231,7 +1722,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1243,7 +1734,7 @@ export class VectorsDB { dimension?: number, permissions?: string[], documentSecurity?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.VectorsdbCollection>; updateCollection( paramsOrFirst: @@ -1254,10 +1745,17 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ...rest: [ + string?, + string?, + number?, + string[]?, + boolean?, + (boolean | null)?, + ] ): Promise<Models.VectorsdbCollection> { let params: { databaseId: string; @@ -1266,7 +1764,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -1281,7 +1779,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -1291,7 +1789,7 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean, + enabled: rest[5] as boolean | null, }; } @@ -1345,7 +1843,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2093,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2291,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2426,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2574,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2727,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2868,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +3035,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3193,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3380,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3567,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3810,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +4006,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4114,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3377,33 +4230,33 @@ export class VectorsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3412,12 +4265,12 @@ export class VectorsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3444,7 +4297,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4457,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4544,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4628,51 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..41404b9 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2415 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise<Models.WafRuleList>; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise<Models.WafRuleList>; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise<Models.WafRuleList> { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + rules: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleBypass>; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleBypass>; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleBypass>; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleBypass>; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise<Models.WafRuleChallenge>; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise<Models.WafRuleChallenge>; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.challengeType - Challenge type enforced by the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }): Promise<Models.WafRuleChallenge>; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} challengeType - Challenge type enforced by the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + challengeType?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + difficulty?: number | null, + ttl?: number | null, + ): Promise<Models.WafRuleChallenge>; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + challengeType: rest[4] as string | null, + priority: rest[5] as number | null, + enabled: rest[6] as boolean | null, + conditions: rest[7] as string[] | null, + difficulty: rest[8] as number | null, + ttl: rest[9] as number | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleDeny>; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleDeny>; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleDeny>; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleDeny>; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRateLimit>; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string | null, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number | null, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRateLimit>; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + (string | null)?, + string?, + string?, + string?, + (number | null)?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number | null, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRateLimit>; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} interval - Interval in seconds used for rate limiting. + * @param {string | null} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + limit?: number | null, + interval?: number | null, + key?: string | null, + maxBucketSize?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRateLimit>; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + limit: rest[4] as number | null, + interval: rest[5] as number | null, + key: rest[6] as string | null, + maxBucketSize: rest[7] as number | null, + priority: rest[8] as number | null, + enabled: rest[9] as boolean | null, + conditions: rest[10] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRedirect>; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRedirect>; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.location - Location used for redirect responses. + * @param {number | null} params.statusCode - Integer status code used for redirect responses. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRedirect>; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} location - Location used for redirect responses. + * @param {number | null} statusCode - Integer status code used for redirect responses. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + location?: string | null, + statusCode?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRedirect>; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + location: rest[4] as string | null, + statusCode: rest[5] as number | null, + priority: rest[6] as number | null, + enabled: rest[7] as boolean | null, + conditions: rest[8] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..32f492f 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,42 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + webhooks: [], + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,9 +122,9 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -97,7 +137,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -108,9 +148,9 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -124,7 +164,7 @@ export class Webhooks { tls?: boolean, authUsername?: string, authPassword?: string, - secret?: string, + secret?: string | null, ): Promise<Models.Webhook>; create( paramsOrFirst: @@ -137,7 +177,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; } | string, ...rest: [ @@ -148,7 +188,7 @@ export class Webhooks { boolean?, string?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -160,7 +200,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; if ( @@ -177,7 +217,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; } else { params = { @@ -189,7 +229,7 @@ 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 | null, }; } @@ -253,7 +293,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +372,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +408,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -333,7 +421,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }): Promise<Models.Webhook>; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -344,8 +432,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -358,7 +446,7 @@ export class Webhooks { enabled?: boolean, tls?: boolean, authUsername?: string, - authPassword?: string, + authPassword?: string | null, ): Promise<Models.Webhook>; update( paramsOrFirst: @@ -370,7 +458,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; } | string, ...rest: [ @@ -380,7 +468,7 @@ export class Webhooks { boolean?, boolean?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -391,7 +479,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; if ( @@ -407,7 +495,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; } else { params = { @@ -418,7 +506,7 @@ 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 | null, }; } @@ -478,7 +566,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -539,29 +651,32 @@ export class Webhooks { * 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. * * @param {string} params.webhookId - Webhook ID. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ updateSecret(params: { webhookId: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * 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. * * @param {string} webhookId - Webhook ID. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; updateSecret( - paramsOrFirst: { webhookId: string; secret?: string } | string, - ...rest: [string?] + webhookId: string, + secret?: string | null, + ): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string; secret?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.Webhook> { - let params: { webhookId: string; secret?: string }; + let params: { webhookId: string; secret?: string | null }; if ( paramsOrFirst && @@ -570,12 +685,12 @@ export class Webhooks { ) { params = (paramsOrFirst || {}) as { webhookId: string; - secret?: string; + secret?: string | null; }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string, + secret: rest[0] as string | null, }; } @@ -602,6 +717,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/topic.ts b/src/topic.ts index cd6cea0..071d5ae 100644 --- a/src/topic.ts +++ b/src/topic.ts @@ -1,6 +1,6 @@ /** * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding - * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). + * the level separator `/` or the MQTT wildcards `+` and `#`. */ function levelsOf(levels: unknown): string[] { if (!Array.isArray(levels)) { @@ -28,17 +28,14 @@ function levelsOf(levels: unknown): string[] { `"${level}" contains "/", split it: path([${parts}])`, ); } - if (level === '+') { - throw new Error('"+" is reserved, use any()'); - } if (level.includes('+')) { - throw new Error(`"${level}" contains "+", use any() for wildcards`); - } - if (level === '#') { - throw new Error('"#" is reserved, use all()'); + throw new Error(`"${level}" contains "+", not allowed in a topic`); } if (level.includes('#')) { - throw new Error(`"${level}" contains "#", use all() for wildcards`); + throw new Error(`"${level}" contains "#", not allowed in a topic`); + } + if (level.includes('\0')) { + throw new Error(`level at index ${index} contains a NUL character`); } return level; }); @@ -48,11 +45,7 @@ function levelsOf(levels: unknown): string[] { * Helper to build MQTT topics for `Push`, level by level. * * Topic.path(['user', userId, 'notification']); // "user/123/notification" - * Topic.path(['user']).any().path(['notification']); // "user/+/notification" - * Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#" - * - * `any()` matches exactly one level and `all()` everything below, at any depth (including the - * parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}. + * Topic.path(['org', orgId]).path(['logs']); // "org/42/logs" */ export class Topic { private constructor(private readonly levels: readonly string[]) {} @@ -62,41 +55,11 @@ export class Topic { return new Topic(levelsOf(levels)); } - /** Start a topic with a single-level wildcard (`+`). */ - static any(): Topic { - return new Topic(['+']); - } - - /** The multi-level wildcard alone (`#`): matches every topic. */ - static all(): ResolvedTopic { - return new ResolvedTopic(['#']); - } - /** Append the given levels. */ path(levels: string[]): Topic { return new Topic([...this.levels, ...levelsOf(levels)]); } - /** Append a single-level wildcard (`+`): matches exactly one level. */ - any(): Topic { - return new Topic([...this.levels, '+']); - } - - /** Append the multi-level wildcard (`#`) and end the topic. */ - all(): ResolvedTopic { - return new ResolvedTopic([...this.levels, '#']); - } - - toString(): string { - return this.levels.join('/'); - } -} - -/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */ -export class ResolvedTopic { - /** @internal Created by {@link Topic.all}. */ - constructor(private readonly levels: readonly string[]) {} - toString(): string { return this.levels.join('/'); } diff --git a/test/client.test.js b/test/client.test.js index 71bda01..82b9451 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -1,5 +1,6 @@ const { Client } = require('../dist/client'); const { InputFile } = require('../dist/inputFile'); +const { Query } = require('../dist/query'); const { fetch: mockedFetch, Response, Dispatcher } = require('undici'); jest.mock('undici', () => ({ @@ -45,6 +46,58 @@ describe('Client', () => { }); }); +describe('Client.prepareRequest', () => { + const url = () => new URL('https://cloud.appwrite.io/v1/rows'); + const params = () => ({ + data: [['a', 'b']], + queries: Query.builder().equal('status', 'active').limit(1), + filters: [Query.equal('status', 'active'), Query.builder().limit(1)], + }); + const queries = [Query.equal('status', 'active'), Query.limit(1)]; + + test('sends nested string arrays and flattened builders as JSON', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'application/json' }, + params(), + ); + + expect(JSON.parse(options.body)).toEqual({ + data: [['a', 'b']], + queries, + filters: queries, + }); + }); + + test('sends nested string arrays and flattened builders as query string', () => { + const { uri } = new Client().prepareRequest('GET', url(), {}, params()); + const search = new URL(uri).searchParams; + + expect(search.get('data[0][0]')).toBe('a'); + expect(search.get('data[0][1]')).toBe('b'); + expect(search.has('data[0]')).toBe(false); + expect([search.get('queries[0]'), search.get('queries[1]')]).toEqual( + queries, + ); + expect([search.get('filters[0]'), search.get('filters[1]')]).toEqual( + queries, + ); + }); + + test('sends flattened builders as multipart fields', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'multipart/form-data' }, + params(), + ); + + expect(options.body.getAll('queries[]')).toEqual(queries); + expect(options.body.getAll('filters[]')).toEqual(queries); + }); +}); + describe('Client.chunkedUpload', () => { const url = new URL( 'https://cloud.appwrite.io/v1/storage/buckets/bucket/files', diff --git a/test/query.test.js b/test/query.test.js index 52e9490..1083ecd 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -1,35 +1,37 @@ -const { Query } = require('../dist/query'); +const { Query, normalizeQueries, flattenParam } = require('../dist/query'); + +const expectQuery = (query) => expect(JSON.parse(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'], }, ]; @@ -37,9 +39,11 @@ 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}}`, - ), + expectQuery(Query.equal('attr', t.value)).toEqual({ + method: 'equal', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -47,9 +51,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.notEqual('attr', t.value)).toEqual({ + method: 'notEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -57,9 +63,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThan('attr', t.value)).toEqual({ + method: 'lessThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -67,9 +75,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThanEqual('attr', t.value)).toEqual({ + method: 'lessThanEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -77,9 +87,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.greaterThan('attr', t.value)).toEqual({ + method: 'greaterThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -87,71 +99,402 @@ describe('Query', () => { 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}}`, - ), + expectQuery(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"]}`, - )); + expectQuery(Query.search('attr', 'keyword1 keyword2')).toEqual({ + method: 'search', + attribute: 'attr', + values: ['keyword1 keyword2'], + })); test('isNull', () => - expect(Query.isNull('attr')).toEqual( - `{"method":"isNull","attribute":"attr"}`, - )); + expectQuery(Query.isNull('attr')).toEqual({ + method: 'isNull', + attribute: 'attr', + })); test('isNotNull', () => - expect(Query.isNotNull('attr')).toEqual( - `{"method":"isNotNull","attribute":"attr"}`, - )); + expectQuery(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]}`, - )); + expectQuery(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]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(Query.select(['attr1', 'attr2'])).toEqual({ + method: 'select', + values: ['attr1', 'attr2'], + })); test('orderAsc', () => - expect(Query.orderAsc('attr')).toEqual( - `{"method":"orderAsc","attribute":"attr"}`, - )); + expectQuery(Query.orderAsc('attr')).toEqual({ + method: 'orderAsc', + attribute: 'attr', + })); test('orderDesc', () => - expect(Query.orderDesc('attr')).toEqual( - `{"method":"orderDesc","attribute":"attr"}`, - )); + expectQuery(Query.orderDesc('attr')).toEqual({ + method: 'orderDesc', + attribute: 'attr', + })); test('cursorBefore', () => - expect(Query.cursorBefore('attr')).toEqual( - '{"method":"cursorBefore","values":["attr"]}', - )); + expectQuery(Query.cursorBefore('attr')).toEqual({ + method: 'cursorBefore', + values: ['attr'], + })); test('cursorAfter', () => - expect(Query.cursorAfter('attr')).toEqual( - '{"method":"cursorAfter","values":["attr"]}', - )); + expectQuery(Query.cursorAfter('attr')).toEqual({ + method: 'cursorAfter', + values: ['attr'], + })); test('limit', () => - expect(Query.limit(1)).toEqual('{"method":"limit","values":[1]}')); + expectQuery(Query.limit(1)).toEqual({ method: 'limit', values: [1] })); test('offset', () => - expect(Query.offset(1)).toEqual('{"method":"offset","values":[1]}')); + expectQuery(Query.offset(1)).toEqual({ + method: 'offset', + values: [1], + })); + + test('count with alias', () => + expectQuery(Query.count('*', 'total')).toEqual({ + method: 'count', + attribute: '*', + values: ['total'], + })); + + test('count without alias', () => + expectQuery(Query.count()).toEqual({ + method: 'count', + attribute: '*', + })); + + test('countDistinct', () => + expectQuery(Query.countDistinct('year', 'uniqueYears')).toEqual({ + method: 'countDistinct', + attribute: 'year', + values: ['uniqueYears'], + })); + + test('sum', () => + expectQuery(Query.sum('price', 'total')).toEqual({ + method: 'sum', + attribute: 'price', + values: ['total'], + })); + + test('avg', () => + expectQuery(Query.avg('price', 'avgPrice')).toEqual({ + method: 'avg', + attribute: 'price', + values: ['avgPrice'], + })); + + test('min', () => + expectQuery(Query.min('price', 'lowest')).toEqual({ + method: 'min', + attribute: 'price', + values: ['lowest'], + })); + + test('max', () => + expectQuery(Query.max('price', 'highest')).toEqual({ + method: 'max', + attribute: 'price', + values: ['highest'], + })); + + test('stddev', () => + expectQuery(Query.stddev('price', 'sd')).toEqual({ + method: 'stddev', + attribute: 'price', + values: ['sd'], + })); + + test('stddevPop', () => + expectQuery(Query.stddevPop('price', 'sdp')).toEqual({ + method: 'stddevPop', + attribute: 'price', + values: ['sdp'], + })); + + test('stddevSamp', () => + expectQuery(Query.stddevSamp('price', 'sds')).toEqual({ + method: 'stddevSamp', + attribute: 'price', + values: ['sds'], + })); + + test('variance', () => + expectQuery(Query.variance('price', 'var')).toEqual({ + method: 'variance', + attribute: 'price', + values: ['var'], + })); + + test('varPop', () => + expectQuery(Query.varPop('price', 'vp')).toEqual({ + method: 'varPop', + attribute: 'price', + values: ['vp'], + })); + + test('varSamp', () => + expectQuery(Query.varSamp('price', 'vs')).toEqual({ + method: 'varSamp', + attribute: 'price', + values: ['vs'], + })); + + test('bitAnd', () => + expectQuery(Query.bitAnd('flags', 'band')).toEqual({ + method: 'bitAnd', + attribute: 'flags', + values: ['band'], + })); + + test('bitOr', () => + expectQuery(Query.bitOr('flags', 'bor')).toEqual({ + method: 'bitOr', + attribute: 'flags', + values: ['bor'], + })); + + test('bitXor', () => + expectQuery(Query.bitXor('flags', 'bxor')).toEqual({ + method: 'bitXor', + attribute: 'flags', + values: ['bxor'], + })); + + test('groupBy', () => + expectQuery(Query.groupBy(['status', 'year'])).toEqual({ + method: 'groupBy', + values: ['status', 'year'], + })); + + test('having nests parsed queries', () => { + const having = JSON.parse( + Query.having([Query.greaterThan('total', 1)]), + ); + expect(having.method).toEqual('having'); + expect(having.values[0].method).toEqual('greaterThan'); + expect(having.values[0].attribute).toEqual('total'); + expect(having.values[0].values).toEqual([1]); + }); + + test('distinct', () => + expectQuery(Query.distinct()).toEqual({ method: 'distinct' })); + + test('join', () => + expectQuery(Query.join('orders', '$id', 'customerId')).toEqual({ + method: 'join', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('leftJoin with alias', () => + expectQuery( + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + ).toEqual({ + method: 'leftJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId', 'ord'], + })); + + test('rightJoin', () => + expectQuery(Query.rightJoin('orders', '$id', 'customerId')).toEqual({ + method: 'rightJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('fullOuterJoin', () => + expectQuery(Query.fullOuterJoin('orders', '$id', 'customerId')).toEqual( + { + method: 'fullOuterJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + }, + )); + + test('on', () => + expectQuery(Query.on('$id', 'customerId')).toEqual({ + method: 'on', + values: ['$id', '=', 'customerId'], + })); + + test('nested leftJoin', () => { + const query = JSON.parse( + Query.leftJoin('orders', 'ord', [ + Query.on('$id', 'customerId'), + Query.equal('ord.status', 'paid'), + ]), + ); + expect(query.method).toEqual('leftJoin'); + expect(query.attribute).toEqual('orders'); + expect(query.values[0]).toEqual('ord'); + expect(query.values[1].method).toEqual('on'); + expect(query.values[2].method).toEqual('equal'); + }); + + test('crossJoin', () => + expectQuery(Query.crossJoin('orders', 'ord')).toEqual({ + method: 'crossJoin', + attribute: 'orders', + values: ['ord'], + })); + + test('vectorDot', () => + expectQuery(Query.vectorDot('embedding', [0.1, 0.2])).toEqual({ + method: 'vectorDot', + attribute: 'embedding', + values: [[0.1, 0.2]], + })); + + test('notCovers', () => + expectQuery(Query.notCovers('location', [1, 2])).toEqual({ + method: 'notCovers', + attribute: 'location', + values: [[1, 2]], + })); + + test('spatialEquals', () => + expectQuery(Query.spatialEquals('location', [1, 2])).toEqual({ + method: 'spatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('notSpatialEquals', () => + expectQuery(Query.notSpatialEquals('location', [1, 2])).toEqual({ + method: 'notSpatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('page', () => { + const queries = Query.page(2, 10).map((query) => JSON.parse(query)); + expect(queries).toEqual([ + { method: 'limit', values: [10] }, + { method: 'offset', values: [10] }, + ]); + }); + + test('builder build', () => { + const built = Query.builder() + .equal('status', 'published') + .leftJoin('orders', '$id', 'customerId', '=', 'ord') + .count('*', 'total') + .groupBy(['status']) + .limit(25) + .build(); + + expect(built).toEqual([ + Query.equal('status', 'published'), + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + Query.count('*', 'total'), + Query.groupBy(['status']), + Query.limit(25), + ]); + }); + + test('normalize builder wrapped in array', () => { + const builder = Query.builder().equal('status', 'active').limit(10); + expect(normalizeQueries([builder])).toEqual(builder.build()); + expect(normalizeQueries([builder.build()])).toEqual(builder.build()); + expect(normalizeQueries(builder)).toEqual(builder.build()); + }); + + test('normalize page wrapped in array', () => { + expect( + normalizeQueries([ + Query.equal('status', 'active'), + Query.page(2, 10), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(10), + Query.offset(10), + ]); + }); + + test('flattenParam spreads wrapped builder', () => { + expect(flattenParam([Query.builder().limit(1)])).toEqual([ + Query.limit(1), + ]); + }); + + test('flattenParam keeps nested numeric arrays', () => { + const geometry = [ + [1, 2], + [3, 4], + ]; + expect(flattenParam(geometry)).toEqual(geometry); + }); + + test('flattenParam keeps query string list', () => { + expect(flattenParam([Query.limit(1)])).toEqual([Query.limit(1)]); + }); + + test('flattenParam keeps nested string arrays', () => { + const value = [['a', 'b']]; + expect(flattenParam(value)).toEqual([['a', 'b']]); + }); + + test('flattenParam builds builders nested in arrays', () => { + expect(flattenParam([[Query.builder().limit(1)]])).toEqual([ + [Query.limit(1)], + ]); + }); + + test('flattenParam builds a builder value', () => { + expect( + flattenParam(Query.builder().equal('status', 'active').limit(1)), + ).toEqual([Query.equal('status', 'active'), Query.limit(1)]); + }); + + test('flattenParam splices builders among query strings', () => { + expect( + flattenParam([ + Query.equal('status', 'active'), + Query.builder().limit(1).offset(2), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(1), + Query.offset(2), + ]); + }); }); diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..0bd3f1c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -13,9 +13,9 @@ describe('Account', () => { 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', + $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, @@ -40,9 +40,9 @@ describe('Account', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Account', () => { }); 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', + $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', @@ -129,9 +129,9 @@ describe('Account', () => { }); 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', + $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', @@ -168,9 +168,9 @@ describe('Account', () => { }); 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', + $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, @@ -221,9 +221,9 @@ describe('Account', () => { }); 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', + $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, @@ -274,9 +274,9 @@ describe('Account', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Account', () => { }); 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', + $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, @@ -348,8 +348,8 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -363,8 +363,8 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -378,9 +378,9 @@ describe('Account', () => { }); 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', + $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', @@ -421,9 +421,9 @@ describe('Account', () => { }); 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', + $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', @@ -568,9 +568,9 @@ describe('Account', () => { }); 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', + $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, @@ -593,11 +593,101 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('<PASSKEY_ID>', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '<PASSKEY_ID>', + {}, + ); + + // 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', + $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, @@ -622,9 +712,9 @@ describe('Account', () => { }); 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', + $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, @@ -659,9 +749,9 @@ describe('Account', () => { }); 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', + $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, @@ -686,8 +776,8 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -706,8 +796,8 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -727,8 +817,8 @@ describe('Account', () => { }); test('test method createRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -744,8 +834,8 @@ describe('Account', () => { }); test('test method updateRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -788,9 +878,9 @@ describe('Account', () => { }); 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', + $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', @@ -828,9 +918,9 @@ describe('Account', () => { }); 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', + $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', @@ -871,9 +961,9 @@ describe('Account', () => { }); test('test method createIdTokenSession()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -914,9 +1004,9 @@ describe('Account', () => { }); 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', + $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', @@ -957,9 +1047,9 @@ describe('Account', () => { }); 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', + $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', @@ -1000,9 +1090,9 @@ describe('Account', () => { }); 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', + $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', @@ -1040,9 +1130,9 @@ describe('Account', () => { }); 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', + $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', @@ -1080,9 +1170,9 @@ describe('Account', () => { }); 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', + $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', @@ -1130,9 +1220,9 @@ describe('Account', () => { }); 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', + $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, @@ -1157,8 +1247,8 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1177,8 +1267,8 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1205,10 +1295,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('<CHALLENGE_ID>', {}); + + // 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', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1227,8 +1350,8 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1246,8 +1369,8 @@ describe('Account', () => { }); test('test method createVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1265,8 +1388,8 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1285,8 +1408,8 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1305,8 +1428,8 @@ describe('Account', () => { }); test('test method createEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1322,8 +1445,8 @@ describe('Account', () => { }); test('test method updateEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1342,8 +1465,8 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1359,8 +1482,8 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 5270074..4c59cab 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', actorType: 'user', actorId: '610fc2f985ee0', actorEmail: 'john@appwrite.io', diff --git a/test/services/advisor.test.js b/test/services/advisor.test.js index 777728a..b3ff64d 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -26,9 +26,9 @@ describe('Advisor', () => { }); 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', + $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/', @@ -71,9 +71,9 @@ describe('Advisor', () => { }); 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', + $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', diff --git a/test/services/apps.test.js b/test/services/apps.test.js index d79c42c..a63e37e 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -26,9 +26,9 @@ describe('Apps', () => { }); 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', + $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', @@ -89,9 +89,9 @@ describe('Apps', () => { }); 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', + $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', @@ -126,9 +126,9 @@ describe('Apps', () => { }); 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', + $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', @@ -186,9 +186,9 @@ describe('Apps', () => { }); 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', + $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: [], @@ -254,9 +254,9 @@ describe('Apps', () => { }); 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', + $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', @@ -273,9 +273,9 @@ describe('Apps', () => { }); 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', + $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', @@ -302,9 +302,9 @@ describe('Apps', () => { }); 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', + $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', @@ -352,9 +352,9 @@ describe('Apps', () => { }); 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', + $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', @@ -371,9 +371,9 @@ describe('Apps', () => { }); 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', + $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', @@ -400,9 +400,9 @@ describe('Apps', () => { }); 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', + $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', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index c65b1b9..ecd4504 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -84,9 +84,9 @@ describe('Avatars', () => { }); test('test method updatePhoto()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 922f68d..e1db580 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -26,9 +26,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -45,9 +45,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -87,10 +87,10 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -113,10 +113,10 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -134,10 +134,10 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -165,9 +165,9 @@ describe('Backups', () => { }); 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', + $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', @@ -199,9 +199,9 @@ describe('Backups', () => { }); 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', + $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', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2af87b0..502bcb0 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -26,10 +26,10 @@ describe('Databases', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -56,9 +56,9 @@ describe('Databases', () => { }); 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', + $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', @@ -73,9 +73,9 @@ describe('Databases', () => { }); 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', + $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', @@ -90,9 +90,9 @@ describe('Databases', () => { }); 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', + $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', @@ -117,9 +117,9 @@ describe('Databases', () => { }); 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', + $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', @@ -134,10 +134,10 @@ describe('Databases', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -151,10 +151,10 @@ describe('Databases', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,10 +191,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -218,10 +218,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -244,10 +244,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -304,8 +304,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -327,8 +327,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -351,8 +351,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -374,8 +374,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -398,8 +398,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -422,8 +422,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -447,8 +447,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -471,8 +471,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -496,8 +496,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -522,8 +522,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -549,8 +549,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -572,8 +572,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -596,8 +596,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -619,8 +619,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -643,8 +643,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -667,8 +667,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -692,8 +692,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -715,8 +715,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -738,8 +738,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -761,8 +761,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -785,8 +785,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -808,8 +808,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -832,8 +832,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -855,8 +855,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -878,8 +878,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -901,8 +901,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -924,8 +924,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -953,8 +953,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -981,8 +981,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1006,8 +1006,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1031,8 +1031,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1054,8 +1054,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1078,8 +1078,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1102,8 +1102,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1127,8 +1127,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1152,8 +1152,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1177,8 +1177,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1225,13 +1225,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1314,13 +1314,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1336,13 +1336,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1358,13 +1358,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1394,13 +1394,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1417,13 +1417,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1456,9 +1456,9 @@ describe('Databases', () => { }); 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', + $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', @@ -1482,9 +1482,9 @@ describe('Databases', () => { }); 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', + $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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..b56872d 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -26,10 +26,10 @@ describe('DocumentsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -132,9 +132,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -149,10 +149,10 @@ describe('DocumentsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -166,10 +166,10 @@ describe('DocumentsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -206,10 +206,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -259,10 +259,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -315,13 +315,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -404,13 +404,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -426,13 +426,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -448,13 +448,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -484,13 +484,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -507,13 +507,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -546,9 +546,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -572,9 +572,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -610,21 +610,17 @@ describe('DocumentsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/domains.test.js b/test/services/domains.test.js index fc86018..f77cb0e 100644 --- a/test/services/domains.test.js +++ b/test/services/domains.test.js @@ -26,9 +26,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -79,9 +79,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -112,9 +112,9 @@ describe('Domains', () => { }); test('test method updateNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -135,9 +135,9 @@ describe('Domains', () => { }); test('test method verifyNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -328,9 +328,9 @@ describe('Domains', () => { }); test('test method createRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -356,9 +356,9 @@ describe('Domains', () => { }); test('test method updateRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -385,9 +385,9 @@ describe('Domains', () => { }); test('test method createRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -413,9 +413,9 @@ describe('Domains', () => { }); test('test method updateRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -442,9 +442,9 @@ describe('Domains', () => { }); test('test method createRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -470,9 +470,9 @@ describe('Domains', () => { }); test('test method updateRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -499,9 +499,9 @@ describe('Domains', () => { }); test('test method createRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -527,9 +527,9 @@ describe('Domains', () => { }); test('test method updateRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -556,9 +556,9 @@ describe('Domains', () => { }); test('test method createRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -584,9 +584,9 @@ describe('Domains', () => { }); test('test method updateRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -613,9 +613,9 @@ describe('Domains', () => { }); test('test method createRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -641,9 +641,9 @@ describe('Domains', () => { }); test('test method updateRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -670,9 +670,9 @@ describe('Domains', () => { }); test('test method createRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -699,9 +699,9 @@ describe('Domains', () => { }); test('test method updateRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -729,9 +729,9 @@ describe('Domains', () => { }); test('test method createRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -757,9 +757,9 @@ describe('Domains', () => { }); test('test method updateRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -786,9 +786,9 @@ describe('Domains', () => { }); test('test method createRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -817,9 +817,9 @@ describe('Domains', () => { }); test('test method updateRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -849,9 +849,9 @@ describe('Domains', () => { }); test('test method createRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -876,9 +876,9 @@ describe('Domains', () => { }); test('test method updateRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -905,9 +905,9 @@ describe('Domains', () => { }); test('test method getRecord()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -941,9 +941,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -988,9 +988,9 @@ describe('Domains', () => { }); test('test method updateZone()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', diff --git a/test/services/functions.test.js b/test/services/functions.test.js index fba574b..78f0a33 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -27,9 +27,9 @@ describe('Functions', () => { }); 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', + $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, @@ -59,6 +59,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.create( @@ -100,9 +101,9 @@ describe('Functions', () => { }); 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', + $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, @@ -132,6 +133,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.get('<FUNCTION_ID>'); @@ -143,9 +145,9 @@ describe('Functions', () => { }); 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', + $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, @@ -175,6 +177,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.update('<FUNCTION_ID>', '<NAME>'); @@ -196,9 +199,9 @@ describe('Functions', () => { }); 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', + $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, @@ -228,6 +231,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.updateFunctionDeployment( @@ -255,9 +259,9 @@ describe('Functions', () => { }); 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', + $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', @@ -300,9 +304,9 @@ describe('Functions', () => { }); 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', + $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', @@ -344,9 +348,9 @@ describe('Functions', () => { }); 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', + $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', @@ -392,9 +396,9 @@ describe('Functions', () => { }); 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', + $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', @@ -437,9 +441,9 @@ describe('Functions', () => { }); 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', + $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', @@ -507,9 +511,9 @@ describe('Functions', () => { }); 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', + $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', @@ -564,10 +568,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -593,10 +597,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -651,9 +655,9 @@ describe('Functions', () => { }); 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', + $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, @@ -675,9 +679,9 @@ describe('Functions', () => { }); 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', + $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, @@ -697,9 +701,9 @@ describe('Functions', () => { }); 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', + $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, diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 25df258..3ffc4e3 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -26,9 +26,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -51,9 +51,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -72,9 +72,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -93,9 +93,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -114,9 +114,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -135,9 +135,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -156,9 +156,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -177,9 +177,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -198,9 +198,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -255,9 +255,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -277,9 +277,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -299,9 +299,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -318,9 +318,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -337,9 +337,9 @@ describe('Messaging', () => { }); test('test method createAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -359,9 +359,9 @@ describe('Messaging', () => { }); test('test method updateAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -379,9 +379,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -401,9 +401,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -423,9 +423,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -442,9 +442,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -461,9 +461,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -483,9 +483,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -502,9 +502,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -524,9 +524,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -543,9 +543,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -565,9 +565,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -584,9 +584,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -606,9 +606,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -626,9 +626,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -648,9 +648,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -667,9 +667,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -690,9 +690,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -713,9 +713,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -732,9 +732,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -751,9 +751,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -773,9 +773,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -793,9 +793,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -815,9 +815,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -835,9 +835,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -857,9 +857,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -876,9 +876,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -898,9 +898,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -917,9 +917,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -959,9 +959,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -978,9 +978,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -997,9 +997,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -1039,9 +1039,9 @@ describe('Messaging', () => { }); 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', + $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', @@ -1063,9 +1063,9 @@ describe('Messaging', () => { }); 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', + $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', diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..9430d54 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -26,21 +26,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mongo', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mongo', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mongo', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mongo', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mongo', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mongo', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -586,21 +566,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -647,21 +623,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -712,21 +684,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -829,17 +797,13 @@ describe('Mongo', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -852,17 +816,13 @@ describe('Mongo', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -876,6 +836,28 @@ describe('Mongo', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -900,21 +882,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..29ef428 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -26,21 +26,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mysql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mysql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mysql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mysql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mysql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mysql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -603,21 +583,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -664,21 +640,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -729,21 +701,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -888,17 +856,13 @@ describe('Mysql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -911,17 +875,13 @@ describe('Mysql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -935,6 +895,28 @@ describe('Mysql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -959,21 +941,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 476045a..79d73e5 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -70,9 +70,9 @@ describe('Oauth2', () => { }); 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', + $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: [], @@ -94,9 +94,9 @@ describe('Oauth2', () => { }); 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', + $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: [], diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..e955287 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -13,9 +13,9 @@ describe('Organization', () => { 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', + $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: {}, @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -46,9 +39,9 @@ describe('Organization', () => { }); 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', + $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: {}, @@ -57,13 +50,6 @@ describe('Organization', () => { 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', @@ -102,9 +88,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -122,9 +108,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -143,9 +129,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -188,9 +174,9 @@ describe('Organization', () => { }); 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', + $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', @@ -214,9 +200,9 @@ describe('Organization', () => { }); 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', + $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', @@ -240,9 +226,9 @@ describe('Organization', () => { }); 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', + $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', @@ -292,9 +278,9 @@ describe('Organization', () => { }); 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', + $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', @@ -332,9 +318,9 @@ describe('Organization', () => { }); 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', + $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', @@ -369,9 +355,9 @@ describe('Organization', () => { }); 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', + $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', @@ -432,9 +418,9 @@ describe('Organization', () => { }); test('test method createEphemeralProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -456,9 +442,9 @@ describe('Organization', () => { }); test('test method getProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -479,9 +465,9 @@ describe('Organization', () => { }); test('test method updateProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..3b5fe88 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -26,21 +26,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Postgresql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Postgresql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Postgresql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Postgresql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Postgresql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -445,21 +433,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,21 +490,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -570,8 +550,8 @@ describe('Postgresql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -623,21 +603,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -687,21 +663,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -751,21 +723,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -812,21 +780,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -877,21 +841,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1039,17 +999,13 @@ describe('Postgresql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1062,17 +1018,13 @@ describe('Postgresql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1086,6 +1038,28 @@ describe('Postgresql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -1110,21 +1084,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/presences.test.js b/test/services/presences.test.js index b388216..ee08169 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -26,10 +26,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -43,10 +43,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -64,10 +64,10 @@ describe('Presences', () => { }); 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': [], + $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', }; diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..13066dc 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -13,9 +13,9 @@ describe('Project', () => { 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', + $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', @@ -60,9 +60,9 @@ describe('Project', () => { }); 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', + $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', @@ -95,6 +95,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment('<ENVIRONMENT_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment('<ENVIRONMENT_ID>'); + + // 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, @@ -110,9 +250,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -130,9 +270,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -150,9 +290,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -180,9 +320,9 @@ describe('Project', () => { }); 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', + $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', @@ -232,8 +372,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -247,8 +387,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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'); @@ -262,8 +402,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -298,9 +438,9 @@ describe('Project', () => { }); 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', + $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', @@ -338,7 +478,7 @@ describe('Project', () => { }); test('test method updateOAuth2Amazon()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', @@ -355,7 +495,7 @@ describe('Project', () => { }); test('test method updateOAuth2Apple()', async () => { const data = { - '\\$id': 'apple', + $id: 'apple', enabled: true, serviceId: 'ip.appwrite.app.web', keyId: 'P4000000N8', @@ -374,7 +514,7 @@ describe('Project', () => { }); test('test method updateOAuth2Appwrite()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a42000000000000b5a0', clientSecret: @@ -390,7 +530,7 @@ describe('Project', () => { }); test('test method updateOAuth2Auth0()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'OaOkIA000000000000000000005KLSYq', clientSecret: @@ -408,7 +548,7 @@ describe('Project', () => { }); test('test method updateOAuth2Authentik()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dTKOPa0000000000000000000000000000e7G8hv', clientSecret: @@ -425,7 +565,7 @@ describe('Project', () => { }); test('test method updateOAuth2Autodesk()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '5zw90v00000000000000000000kVYXN7', clientSecret: '7I000000000000MW', @@ -440,7 +580,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitbucket()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, key: 'Knt70000000000ByRc', secret: 'NMfLZJ00000000000000000000TLQdDx', @@ -455,7 +595,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitly()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'd95151000000000000000000000000000067af9b', clientSecret: 'a13e250000000000000000000000000000d73095', @@ -470,7 +610,7 @@ describe('Project', () => { }); test('test method updateOAuth2Box()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'deglcs00000000000000000000x2og6y', clientSecret: 'OKM1f100000000000000000000eshEif', @@ -485,7 +625,7 @@ describe('Project', () => { }); test('test method updateOAuth2Cloudflare()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '4b866000000000000000000000c9e4e2', clientSecret: @@ -501,7 +641,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dailymotion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, apiKey: '07a9000000000000067f', apiSecret: 'a399a90000000000000000000000000000d90639', @@ -516,7 +656,7 @@ describe('Project', () => { }); test('test method updateOAuth2Discord()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '950722000000343754', clientSecret: 'YmPXnM000000000000000000002zFg5D', @@ -532,7 +672,7 @@ describe('Project', () => { }); test('test method updateOAuth2Disqus()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, publicKey: 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', @@ -549,7 +689,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dropbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appKey: 'jl000000000009t', appSecret: 'g200000000000vw', @@ -564,7 +704,7 @@ describe('Project', () => { }); test('test method updateOAuth2Etsy()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, keyString: 'nsgzxh0000000000008j85a2', sharedSecret: 'tp000000ru', @@ -579,7 +719,7 @@ describe('Project', () => { }); test('test method updateOAuth2Facebook()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appId: '260600000007694', appSecret: '2d0b2800000000000000000000d38af4', @@ -594,7 +734,7 @@ describe('Project', () => { }); test('test method updateOAuth2Figma()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'byay5H0000000000VtiI40', clientSecret: 'yEpOYn0000000000000000004iIsU5', @@ -609,7 +749,7 @@ describe('Project', () => { }); test('test method updateOAuth2FusionAuth()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'b2222c00-0000-0000-0000-000000862097', clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', @@ -625,7 +765,7 @@ describe('Project', () => { }); test('test method updateOAuth2GitHub()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'e4d87900000000540733', clientSecret: '5e07c00000000000000000000000000000198bcc', @@ -641,7 +781,7 @@ describe('Project', () => { }); test('test method updateOAuth2Gitlab()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', @@ -658,7 +798,7 @@ describe('Project', () => { }); test('test method updateOAuth2Google()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', @@ -677,7 +817,7 @@ describe('Project', () => { }); test('test method updateOAuth2HuggingFace()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', @@ -692,7 +832,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kakao()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -708,7 +848,7 @@ describe('Project', () => { }); test('test method updateOAuth2Keycloak()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-o0000000st-app', clientSecret: 'jdjrJd00000000000000000000HUsaZO', @@ -725,7 +865,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kick()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '01KQ7C00000000000001MFHS32', clientSecret: @@ -741,7 +881,7 @@ describe('Project', () => { }); test('test method updateOAuth2Linkedin()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '770000000000dv', primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', @@ -756,7 +896,7 @@ describe('Project', () => { }); test('test method updateOAuth2Microsoft()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', @@ -773,7 +913,7 @@ describe('Project', () => { }); test('test method updateOAuth2Notion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauthClientId: '341d8700-0000-0000-0000-000000446ee3', oauthClientSecret: @@ -789,7 +929,7 @@ describe('Project', () => { }); test('test method updateOAuth2Oidc()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'qibI2x0000000000000000000000000006L2YFoG', clientSecret: @@ -811,7 +951,7 @@ describe('Project', () => { }); test('test method updateOAuth2Okta()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '0oa00000000000000698', clientSecret: @@ -830,7 +970,7 @@ describe('Project', () => { }); test('test method updateOAuth2Paypal()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -847,7 +987,7 @@ describe('Project', () => { }); test('test method updateOAuth2PaypalSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -864,7 +1004,7 @@ describe('Project', () => { }); test('test method updateOAuth2Podio()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-oauth-test-app', clientSecret: @@ -880,7 +1020,7 @@ describe('Project', () => { }); test('test method updateOAuth2Resend()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', clientSecret: @@ -896,7 +1036,7 @@ describe('Project', () => { }); test('test method updateOAuth2Salesforce()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', @@ -913,7 +1053,7 @@ describe('Project', () => { }); test('test method updateOAuth2Slack()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '23000000089.15000000000023', clientSecret: '81656000000000000000000000f3d2fd', @@ -928,7 +1068,7 @@ describe('Project', () => { }); test('test method updateOAuth2Spotify()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6ec271000000000000000000009beace', clientSecret: 'db068a000000000000000000008b5b9f', @@ -943,7 +1083,7 @@ describe('Project', () => { }); test('test method updateOAuth2Stripe()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'ca_UKibXX0000000000000000000006byvR', apiSecretKey: @@ -959,7 +1099,7 @@ describe('Project', () => { }); test('test method updateOAuth2TikTok()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'awz000000000tyw0', clientSecret: '6wXewM00000000000000000000yXnite', @@ -974,7 +1114,7 @@ describe('Project', () => { }); test('test method updateOAuth2Tradeshift()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -989,7 +1129,7 @@ describe('Project', () => { }); test('test method updateOAuth2TradeshiftSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -1004,7 +1144,7 @@ describe('Project', () => { }); test('test method updateOAuth2Twitch()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'vvi0in000000000000000000ikmt9p', clientSecret: 'pmapue000000000000000000zylw3v', @@ -1019,7 +1159,7 @@ describe('Project', () => { }); test('test method updateOAuth2Webflow()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '8bb20000000000000000000000000000000000000000000000000000000040dd', @@ -1036,7 +1176,7 @@ describe('Project', () => { }); test('test method updateOAuth2WordPress()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '130005', clientSecret: @@ -1052,7 +1192,7 @@ describe('Project', () => { }); test('test method updateOAuth2X()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: 'slzZV0000000000000NFLaWT', secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', @@ -1067,7 +1207,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yahoo()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', @@ -1083,7 +1223,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yandex()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a8a6a0000000000000000000091483c', clientSecret: 'bbf98500000000000000000000c75a63', @@ -1098,7 +1238,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoho()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '1000.83C178000000000000000000RPNX0B', clientSecret: 'fb5cac000000000000000000000000000000a68f6e', @@ -1114,7 +1254,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoom()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'QMAC00000000000000w0AQ', clientSecret: 'GAWsG4000000000000000000007U01ON', @@ -1129,7 +1269,7 @@ describe('Project', () => { }); test('test method getOAuth2Provider()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -1158,12 +1298,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1179,12 +1320,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1200,9 +1342,9 @@ describe('Project', () => { }); 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', + $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', @@ -1221,9 +1363,9 @@ describe('Project', () => { }); 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', + $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', @@ -1242,9 +1384,9 @@ describe('Project', () => { }); 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', + $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', @@ -1263,9 +1405,9 @@ describe('Project', () => { }); 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', + $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', @@ -1284,9 +1426,9 @@ describe('Project', () => { }); 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', + $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', @@ -1305,9 +1447,9 @@ describe('Project', () => { }); 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', + $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', @@ -1326,9 +1468,9 @@ describe('Project', () => { }); 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', + $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', @@ -1347,9 +1489,9 @@ describe('Project', () => { }); 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', + $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', @@ -1368,9 +1510,9 @@ describe('Project', () => { }); 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', + $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', @@ -1408,9 +1550,9 @@ describe('Project', () => { }); 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', + $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', @@ -1445,9 +1587,9 @@ describe('Project', () => { }); 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', + $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', @@ -1482,9 +1624,9 @@ describe('Project', () => { }); 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', + $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', @@ -1519,9 +1661,9 @@ describe('Project', () => { }); 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', + $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', @@ -1556,9 +1698,9 @@ describe('Project', () => { }); 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', + $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', @@ -1593,9 +1735,9 @@ describe('Project', () => { }); 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', + $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', @@ -1628,11 +1770,48 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy('<RP_ID>'); + + // 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', + $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', @@ -1667,9 +1846,9 @@ describe('Project', () => { }); 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', + $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', @@ -1704,9 +1883,9 @@ describe('Project', () => { }); 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', + $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', @@ -1741,9 +1920,9 @@ describe('Project', () => { }); test('test method updatePasswordPwnedPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -1776,9 +1955,46 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', + $id: 'password-dictionary', min: 12, uppercase: true, lowercase: true, @@ -1795,9 +2011,9 @@ describe('Project', () => { }); 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', + $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', @@ -1832,9 +2048,9 @@ describe('Project', () => { }); 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', + $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', @@ -1869,9 +2085,9 @@ describe('Project', () => { }); 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', + $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', @@ -1906,9 +2122,9 @@ describe('Project', () => { }); 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', + $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', @@ -1943,9 +2159,9 @@ describe('Project', () => { }); 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', + $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', @@ -1980,8 +2196,9 @@ describe('Project', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', - enabled: true, + $id: 'password-dictionary', + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); @@ -1993,9 +2210,9 @@ describe('Project', () => { }); 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', + $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', @@ -2030,9 +2247,9 @@ describe('Project', () => { }); 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', + $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', @@ -2067,9 +2284,9 @@ describe('Project', () => { }); 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', + $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', @@ -2178,9 +2395,9 @@ describe('Project', () => { }); 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', + $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, @@ -2201,9 +2418,9 @@ describe('Project', () => { }); 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', + $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, @@ -2220,9 +2437,9 @@ describe('Project', () => { }); 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', + $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, diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js index bf9d288..3445b18 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -41,9 +41,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -55,6 +55,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createAPIRule('example.com'); @@ -66,9 +67,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -80,6 +81,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createFunctionRule( @@ -94,9 +96,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -108,6 +110,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createRedirectRule( @@ -125,9 +128,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -139,6 +142,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createSiteRule('example.com', '<SITE_ID>'); @@ -148,11 +152,40 @@ describe('Proxy', () => { expect(response).toEqual(data); }); + test('test method createSMTPRule()', 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', + protocol: 'http', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await proxy.createSMTPRule( + 'example.com', + '<FUNCTION_ID>', + ); + + // 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', + $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', @@ -164,6 +197,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.getRule('<RULE_ID>'); @@ -185,9 +219,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -199,6 +233,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.updateRuleStatus('<RULE_ID>'); diff --git a/test/services/sites.test.js b/test/services/sites.test.js index 8e558d9..cf30e82 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -27,9 +27,9 @@ describe('Sites', () => { }); 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', + $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, @@ -104,9 +104,9 @@ describe('Sites', () => { }); 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', + $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, @@ -150,9 +150,9 @@ describe('Sites', () => { }); 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', + $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, @@ -206,9 +206,9 @@ describe('Sites', () => { }); 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', + $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, @@ -268,9 +268,9 @@ describe('Sites', () => { }); 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', + $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', @@ -312,9 +312,9 @@ describe('Sites', () => { }); 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', + $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', @@ -356,9 +356,9 @@ describe('Sites', () => { }); 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', + $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', @@ -404,9 +404,9 @@ describe('Sites', () => { }); 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', + $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', @@ -449,9 +449,9 @@ describe('Sites', () => { }); 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', + $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', @@ -519,9 +519,9 @@ describe('Sites', () => { }); 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', + $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', @@ -576,10 +576,10 @@ describe('Sites', () => { }); 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': [], + $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', @@ -628,9 +628,9 @@ describe('Sites', () => { }); 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', + $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, @@ -652,9 +652,9 @@ describe('Sites', () => { }); 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', + $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, @@ -671,9 +671,9 @@ describe('Sites', () => { }); 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', + $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, diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 7f35319..b46b168 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -27,10 +27,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -52,10 +52,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -77,10 +77,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -125,11 +125,11 @@ describe('Storage', () => { }); test('test method createFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -156,11 +156,11 @@ describe('Storage', () => { }); test('test method getFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -183,11 +183,11 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..6320233 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -26,10 +26,10 @@ describe('TablesDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('TablesDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('TablesDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,21 +191,17 @@ describe('TablesDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -265,9 +261,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -296,9 +292,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -340,9 +336,9 @@ describe('TablesDB', () => { }); test('test method createCutover()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -436,10 +432,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -463,10 +459,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -486,10 +482,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -546,8 +542,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -569,8 +565,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -593,8 +589,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -616,8 +612,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -640,8 +636,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -664,8 +660,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -689,8 +685,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -713,8 +709,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -738,8 +734,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -764,8 +760,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -791,8 +787,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -814,8 +810,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -838,8 +834,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -861,8 +857,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -885,8 +881,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -909,8 +905,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -934,8 +930,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -957,8 +953,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -980,8 +976,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1003,8 +999,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1027,8 +1023,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1050,8 +1046,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1074,8 +1070,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1097,8 +1093,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1120,8 +1116,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1143,8 +1139,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1166,8 +1162,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1195,8 +1191,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1223,8 +1219,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1248,8 +1244,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1273,8 +1269,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1296,8 +1292,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1320,8 +1316,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1344,8 +1340,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1369,8 +1365,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1394,8 +1390,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1419,8 +1415,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1467,9 +1463,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1493,9 +1489,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1544,13 +1540,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1633,13 +1629,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1655,13 +1651,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1677,13 +1673,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1713,13 +1709,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1736,13 +1732,13 @@ describe('TablesDB', () => { }); 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': [], + $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( diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 7dcf744..0248491 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -26,9 +26,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -43,9 +43,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -60,9 +60,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -100,9 +100,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -123,9 +123,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -146,9 +146,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -195,9 +195,9 @@ describe('Teams', () => { }); 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', + $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', @@ -221,9 +221,9 @@ describe('Teams', () => { }); 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', + $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', @@ -250,9 +250,9 @@ describe('Teams', () => { }); 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', + $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', @@ -293,9 +293,9 @@ describe('Teams', () => { }); 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', + $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', diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index 323ab93..1850b2e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -26,8 +26,8 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -47,8 +47,8 @@ describe('Tokens', () => { }); test('test method get()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -65,8 +65,8 @@ describe('Tokens', () => { }); test('test method update()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..21befd9 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -26,9 +26,9 @@ describe('Users', () => { }); 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', + $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, @@ -53,9 +53,9 @@ describe('Users', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Users', () => { }); 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', + $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, @@ -138,9 +138,9 @@ describe('Users', () => { }); 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', + $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, @@ -169,9 +169,9 @@ describe('Users', () => { }); 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', + $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, @@ -200,9 +200,9 @@ describe('Users', () => { }); 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', + $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, @@ -236,9 +236,9 @@ describe('Users', () => { }); 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', + $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, @@ -270,9 +270,9 @@ describe('Users', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Users', () => { }); 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', + $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, @@ -338,9 +338,9 @@ describe('Users', () => { }); 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', + $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, @@ -368,9 +368,9 @@ describe('Users', () => { }); 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', + $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, @@ -407,9 +407,9 @@ describe('Users', () => { }); 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', + $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, @@ -447,9 +447,9 @@ describe('Users', () => { }); 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', + $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, @@ -474,9 +474,9 @@ describe('Users', () => { }); 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', + $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, @@ -527,8 +527,8 @@ describe('Users', () => { }); test('test method getMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', code: '446372', @@ -650,9 +650,9 @@ describe('Users', () => { }); 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', + $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, @@ -675,11 +675,70 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys('<USER_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('<USER_ID>', '<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '<USER_ID>', + '<PASSKEY_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('<USER_ID>', '<PASSKEY_ID>'); + + // 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', + $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, @@ -704,9 +763,9 @@ describe('Users', () => { }); 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', + $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, @@ -764,9 +823,9 @@ describe('Users', () => { }); 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', + $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', @@ -824,9 +883,9 @@ describe('Users', () => { }); 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', + $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, @@ -864,9 +923,9 @@ describe('Users', () => { }); 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', + $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', @@ -888,9 +947,9 @@ describe('Users', () => { }); 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', + $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', @@ -907,9 +966,9 @@ describe('Users', () => { }); 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', + $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', @@ -936,8 +995,8 @@ describe('Users', () => { }); test('test method createToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -953,9 +1012,9 @@ describe('Users', () => { }); 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', + $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, @@ -980,9 +1039,9 @@ describe('Users', () => { }); 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', + $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, diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..4fe8681 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -26,10 +26,10 @@ describe('VectorsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('VectorsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('VectorsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -204,10 +204,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -260,10 +260,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -317,13 +317,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -422,13 +422,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -444,13 +444,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -466,13 +466,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -518,9 +518,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -544,9 +544,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -582,21 +582,17 @@ describe('VectorsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..1e672a2 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('<RULE_ID>', 'api', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '<RULE_ID>', + 'api', + '<NAME>', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '<RULE_ID>', + 'api', + '<NAME>', + '<LOCATION>', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule('<RULE_ID>'); + + // 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 7f7e54b..d232fb5 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -26,9 +26,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -55,9 +55,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -79,9 +79,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -118,9 +118,9 @@ describe('Webhooks', () => { }); 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', + $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: [], diff --git a/test/topic.test.js b/test/topic.test.js index 44ba8cd..fc5d764 100644 --- a/test/topic.test.js +++ b/test/topic.test.js @@ -9,24 +9,10 @@ describe('Topic', () => { expect(Topic.path(['user']).path(['notification']).toString()).toEqual( 'user/notification', ); - }); - test('any', () => { - expect( - Topic.path(['user']).any().path(['notification']).toString(), - ).toEqual('user/+/notification'); - expect( - Topic.path(['chat']).any().any().path(['message']).toString(), - ).toEqual('chat/+/+/message'); - expect(Topic.any().path(['notification']).toString()).toEqual( - '+/notification', + expect(Topic.path(['org', '42']).path(['logs']).toString()).toEqual( + 'org/42/logs', ); }); - test('all', () => { - expect( - Topic.path(['org']).any().path(['logs']).all().toString(), - ).toEqual('org/+/logs/#'); - expect(Topic.all().toString()).toEqual('#'); - }); test.each([ ['an empty path', []], ['an empty level', ['user', '']], @@ -35,10 +21,11 @@ describe('Topic', () => { ['an embedded +', ['user', 'a+b']], ['a lone #', ['user', '#']], ['an embedded #', ['user', 'a#b']], + ['a NUL character', ['user', 'a\u0000b']], ['a non-string level', ['user', null]], ['a non-array', 'user'], ])('rejects %s', (_, levels) => { expect(() => Topic.path(levels)).toThrow(Error); - expect(() => Topic.any().path(levels)).toThrow(Error); + expect(() => Topic.path(['user']).path(levels)).toThrow(Error); }); }); From a8e771af9014c509e9f802c7320451e7fa0936e6 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal <chiragaggarwal5k@gmail.com> Date: Thu, 15 Oct 2026 13:19:17 +0100 Subject: [PATCH 7/7] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 92 +- README.md | 58 +- .../examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-passkey-token.md | 12 + docs/examples/account/create-passkey.md | 15 + docs/examples/account/delete-passkey.md | 14 + docs/examples/account/get-passkey.md | 14 + docs/examples/account/list-passkeys.md | 15 + docs/examples/account/update-passkey-token.md | 15 + .../account/update-passkey-verification.md | 15 + docs/examples/account/update-passkey.md | 15 + docs/examples/domains/get-price.md | 2 +- docs/examples/domains/list-prices.md | 2 +- docs/examples/functions/create.md | 1 + docs/examples/functions/update.md | 2 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/update-email.md | 10 +- docs/examples/messaging/update-push.md | 4 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/mongo/create-restoration.md | 3 + docs/examples/mongo/promote-restoration.md | 15 + docs/examples/mysql/create-restoration.md | 3 + docs/examples/mysql/promote-restoration.md | 15 + docs/examples/oauth2/authorize-post.md | 2 +- docs/examples/oauth2/authorize.md | 2 +- .../oauth2/create-device-authorization.md | 2 +- docs/examples/oauth2/create-par.md | 2 +- docs/examples/oauth2/create-token.md | 2 +- .../examples/postgresql/create-restoration.md | 3 + .../postgresql/promote-restoration.md | 15 + .../project/create-android-platform.md | 1 + docs/examples/project/create-environment.md | 15 + docs/examples/project/delete-environment.md | 14 + docs/examples/project/get-environment.md | 14 + docs/examples/project/list-environments.md | 15 + .../project/update-android-platform.md | 1 + docs/examples/project/update-environment.md | 15 + .../examples/project/update-o-auth-2-apple.md | 2 +- .../project/update-o-auth-2-auth-0.md | 2 +- .../project/update-o-auth-2-discord.md | 2 +- .../project/update-o-auth-2-git-hub.md | 2 +- .../project/update-o-auth-2-google.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 2 +- .../project/update-o-auth-2-microsoft.md | 2 +- docs/examples/project/update-o-auth-2-okta.md | 2 +- .../project/update-o-auth-2-salesforce.md | 2 +- docs/examples/project/update-o-auth-2-zoho.md | 2 +- .../examples/project/update-passkey-policy.md | 14 + .../update-password-rotation-policy.md | 15 + docs/examples/proxy/create-smtp-rule.md | 16 + docs/examples/teams/create-membership.md | 1 + docs/examples/users/delete-passkey.md | 15 + docs/examples/users/get-passkey.md | 15 + docs/examples/users/list-passkeys.md | 16 + docs/examples/users/update-passkey.md | 16 + docs/examples/waf/create-bypass-rule.md | 21 + docs/examples/waf/create-challenge-rule.md | 24 + docs/examples/waf/create-deny-rule.md | 21 + docs/examples/waf/create-rate-limit-rule.md | 26 + docs/examples/waf/create-redirect-rule.md | 23 + docs/examples/waf/delete-rule.md | 14 + docs/examples/waf/get-rule.md | 14 + docs/examples/waf/list-rules.md | 16 + docs/examples/waf/update-bypass-rule.md | 21 + docs/examples/waf/update-challenge-rule.md | 24 + docs/examples/waf/update-deny-rule.md | 21 + docs/examples/waf/update-rate-limit-rule.md | 25 + docs/examples/waf/update-redirect-rule.md | 23 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 88 +- src/enums/databases-index-type.ts | 1 + src/enums/execution-trigger.ts | 1 + src/enums/project-auth-method-id.ts | 1 + src/enums/project-key-scopes.ts | 2 + src/enums/project-policy-id.ts | 2 + src/enums/proxy-rule-protocol.ts | 4 + src/enums/tables-db-index-type.ts | 1 + src/enums/waf-rule-action.ts | 7 + src/index.ts | 15 +- src/models.ts | 1150 ++- src/query.ts | 809 ++ src/services/account.ts | 2254 ++++- src/services/activities.ts | 102 +- src/services/advisor.ts | 229 +- src/services/apps.ts | 633 +- src/services/backups.ts | 355 +- src/services/databases.ts | 3189 +++++-- src/services/documents-db.ts | 1179 ++- src/services/domains.ts | 1398 ++- src/services/embeddings.ts | 35 +- src/services/functions.ts | 1077 ++- src/services/locale.ts | 211 +- src/services/messaging.ts | 3171 ++++--- src/services/mongo.ts | 1826 +++- src/services/mysql.ts | 2084 ++++- src/services/oauth-2.ts | 359 +- src/services/organization.ts | 735 +- src/services/postgresql.ts | 2229 ++++- src/services/presences.ts | 94 +- src/services/project.ts | 7877 +++++++++++++---- src/services/proxy.ts | 340 +- src/services/sites.ts | 979 +- src/services/storage.ts | 326 +- src/services/tables-db.ts | 3648 ++++++-- src/services/teams.ts | 380 +- src/services/tokens.ts | 142 +- src/services/users.ts | 1808 +++- src/services/vectors-db.ts | 1181 ++- src/services/waf.ts | 2415 +++++ src/services/webhooks.ts | 217 +- src/topic.ts | 51 +- test/client.test.js | 53 + test/query.test.js | 463 +- test/services/account.test.js | 329 +- test/services/activities.test.js | 2 +- test/services/advisor.test.js | 12 +- test/services/apps.test.js | 60 +- test/services/avatars.test.js | 6 +- test/services/backups.test.js | 42 +- test/services/databases.test.js | 310 +- test/services/documents-d-b.test.js | 172 +- test/services/domains.test.js | 162 +- test/services/functions.test.js | 98 +- test/services/messaging.test.js | 282 +- test/services/mongo.test.js | 162 +- test/services/mysql.test.js | 162 +- test/services/oauth2.test.js | 12 +- test/services/organization.test.js | 98 +- test/services/postgresql.test.js | 182 +- test/services/presences.test.js | 24 +- test/services/project.test.js | 569 +- test/services/proxy.test.js | 71 +- test/services/sites.test.js | 86 +- test/services/storage.test.js | 48 +- test/services/tables-d-b.test.js | 338 +- test/services/teams.test.js | 60 +- test/services/tokens.test.js | 12 +- test/services/users.test.js | 211 +- test/services/vectors-d-b.test.js | 144 +- test/services/waf.test.js | 354 + test/services/webhooks.test.js | 24 +- test/topic.test.js | 21 +- 143 files changed, 39227 insertions(+), 8786 deletions(-) create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md create mode 100644 docs/examples/account/list-passkeys.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/mongo/promote-restoration.md create mode 100644 docs/examples/mysql/promote-restoration.md create mode 100644 docs/examples/postgresql/promote-restoration.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/proxy/create-smtp-rule.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md create mode 100644 docs/examples/users/list-passkeys.md create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/proxy-rule-protocol.ts create mode 100644 src/enums/waf-rule-action.ts create mode 100644 src/services/waf.ts create mode 100644 test/services/waf.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f79a0ae..27c2f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,70 @@ # Change Log -## 30.0.0-rc.2 - -* Added: OAuth2 provider `prompt` enums (`OAuth2Auth0Prompt`, `OAuth2GithubPrompt`, and project variants) -* Added: `Topic` and `ResolvedTopic` exports -* Added: `Models.Account` and `Models.OAuth2Webflow` types -* Added: `Webflow` to the `OAuthProvider` and `ProjectOAuthProviderId` enums -* Added: `avatars.updatePhoto()` and `avatars.deletePhoto()` methods -* Added: optional `total` param on locale and list endpoints; `duration` on email-password sessions -* Updated: `chunkedUpload` supports a `text` responseType and falls back without a file -* Updated: several model fields relaxed to optional; `RestorationStatus.options` is now an object - -## 30.0.0 - -* Breaking: `account.listLogs`, `users.listLogs`, `Log` and `LogList` removed -* Breaking: `organization` key methods renamed to `createEphemeralProjectKey`, `getProjectKey`, `listProjectKeys`, `updateProjectKey`, `deleteProjectKey`, and `OrganizationKeyScopes` removed -* Breaking: `setDevKey` client method, `DevKey` model and `Project.devKeys` removed -* Breaking: `region`, `reason`, `projectName`, `organizationId`, `organizationName`, `billingPlan` removed from `Block` -* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on each `DedicatedDatabaseSpecification` -* Breaking: `BillingPlanGroup.Starter` replaced by `Free` and `Start` -* Added: `oauth2.introspect` for RFC 7662 token introspection with an API key, returning the `Oauth2Introspection` model -* Added: `domains` service for domains, DNS records, email presets, prices and transfers -* Added: `account.createIdTokenSession` and email verification and recovery OTP methods +## 30.0.1 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.listLogs`, `users.listLogs` and the `Models.Log`/`Models.LogList` models +* Breaking: removed `organization.createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `organization.listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead +* Breaking: removed `Client.setDevKey`, `Models.DevKey` and `Project.devKeys` +* Breaking: removed `BillingPlanGroup.Starter`; use `BillingPlanGroup.Free` +* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `string[]` +* Breaking: `project.updateOAuth2Kakao` takes `enabled` before `prompt` +* Breaking: `BackupRestoration.options` is now an object +* Breaking: nullable response fields are typed `T | null`; some became optional, such as `BillingPlan.usage` +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `mongo`, `mysql` and `postgresql` `promoteRestoration`, `restoreMode`, `targetName` and `autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration.restoreMode` +* Added: `proxy.createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule.protocol` +* Added: `emailEnabled` on `functions.update` and `Function`, and `ExecutionTrigger.Email` +* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page` +* Added: `Query.builder()` to chain queries into a list +* Updated: nullable request params accept `null`, such as `qos` on topics and the Appwrite provider +* Updated: missing response fields fall back to their documented defaults +* Updated: OAuth2 `prompt` and native fields, `PlatformAndroid.fingerprints` and `Identity.providerIdToken` are always returned +* Fixed: list and object defaults filled into a response are copied per model, and object defaults are `{}` instead of `[]` + +## 29.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` * Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` -* Added: `project.updatePasswordPwnedPolicy` with `PolicyPasswordPwned` model and `User.passwordPwned` -* Added: Kakao and TikTok OAuth2 providers -* Added: native client IDs on the Apple and Google OAuth2 providers -* Added: reply-to on email messages, `qos` and `expiry` on topics -* Added: `ImageGravity.Auto`, `jaspr` framework, and `dart-3.13` and `flutter-3.47` runtimes -* Updated: requests send `X-Appwrite-Response-Format` `2.3.0` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + +## 29.3.1 + +* Fixed: added `ProjectAuthMethodId.Passkey`, so `project.updateAuthMethod` can enable passkeys +* Fixed: added `ProjectPolicyId.Passkey` and the `Models.PolicyPasskey` model, so `getPolicy` and `listPolicies` return the passkey policy + +## 29.3.0 + +* Added: `account` passkey methods `listPasskeys`, `createPasskey`, `getPasskey`, `updatePasskey`, `deletePasskey` and `updatePasskeyVerification` +* Added: `account.createPasskeyToken` and `account.updatePasskeyToken` for passkey sign-in +* Added: `users.listPasskeys`, `users.getPasskey`, `users.updatePasskey` and `users.deletePasskey` +* Added: `project.updatePasskeyPolicy` to configure passkey sign-in +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge` and `TokenSecret` models + +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs ## 29.0.0 diff --git a/README.md b/README.md index 900e4e2..a2881b8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 2.3.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-node/releases) when APIs differ. > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) @@ -50,7 +50,13 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```js let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -73,7 +79,13 @@ client ; let users = new sdk.Users(client); -let promise = users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); +let promise = users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); promise.then(function (response) { console.log(response); @@ -84,11 +96,11 @@ promise.then(function (response) { ### Type Safety with Models -The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. +The Appwrite Node SDK provides type safety when working with table rows through generic methods. Methods like `listRows`, `getRow`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety. **TypeScript:** ```typescript -interface Book { +interface Book extends Models.Row { name: string; author: string; releaseYear?: string; @@ -97,15 +109,15 @@ interface Book { isCheckedOut: boolean; } -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - const documents = await databases.listDocuments<Book>( - 'your-database-id', - 'your-collection-id' - ); + const result = await tablesDB.listRows<Book>({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety }); } catch (error) { @@ -125,16 +137,16 @@ try { * @property {boolean} isCheckedOut */ -const databases = new Databases(client); +const tablesDB = new TablesDB(client); try { - /** @type {Models.DocumentList<Book>} */ - const documents = await databases.listDocuments( - 'your-database-id', - 'your-collection-id' - ); + /** @type {Models.RowList<Book>} */ + const result = await tablesDB.listRows({ + databaseId: 'your-database-id', + tableId: 'your-table-id' + }); - documents.documents.forEach(book => { + result.rows.forEach(book => { console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE }); } catch (error) { @@ -152,7 +164,13 @@ The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` a let users = new sdk.Users(client); try { - let res = await users.create(sdk.ID.unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); + let res = await users.create({ + userId: sdk.ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" +}); } catch(e) { console.log(e.message); } diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '<STATE>', // optional }); ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 0000000..cf4a5c7 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,12 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskeyToken(); +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 0000000..50bdf74 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.createPasskey({ + passkeyId: '<PASSKEY_ID>', // optional + name: '<NAME>', // optional +}); +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 0000000..d19b717 --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.deletePasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 0000000..3a125d0 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.getPasskey({ + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md new file mode 100644 index 0000000..403da40 --- /dev/null +++ b/docs/examples/account/list-passkeys.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.listPasskeys({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 0000000..1bdc685 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyToken({ + challengeId: '<CHALLENGE_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 0000000..d3294a1 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskeyVerification({ + passkeyId: '<PASSKEY_ID>', + credential: {}, +}); +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 0000000..f296b3e --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const account = new sdk.Account(client); + +const result = await account.updatePasskey({ + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index ff77675..893f3f0 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.getPrice({ domain: 'example.com', - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index bcf3572..86de02c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -10,7 +10,7 @@ const domains = new sdk.Domains(client); const result = await domains.listPrices({ domains: [], - periodYears: null, // optional + periodYears: 1, // optional registrationType: sdk.DomainRegistrationType.New, // optional }); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..a9c4c9d 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,7 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional + emailEnabled: false, // optional }); ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 499e392..256234c 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -18,10 +18,10 @@ const result = await messaging.createEmail({ cc: [], // optional bcc: [], // optional attachments: [], // optional - replyToEmail: 'email@example.com', // optional - replyToName: '<REPLY_TO_NAME>', // optional draft: false, // optional html: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional }); ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 04e86f7..0fc7a9a 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -10,18 +10,18 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateEmail({ messageId: '<MESSAGE_ID>', - subject: '<SUBJECT>', // optional - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional cc: [], // optional bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional attachments: [], // optional replyToEmail: 'email@example.com', // optional replyToName: '<REPLY_TO_NAME>', // optional - draft: false, // optional - html: false, // optional - scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index d62e346..5d0e6b7 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -10,11 +10,11 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updatePush({ messageId: '<MESSAGE_ID>', - title: '<TITLE>', // optional - body: '<BODY>', // optional topics: [], // optional users: [], // optional targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional data: {}, // optional action: '<ACTION>', // optional image: '<ID1:ID2>', // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 7c95f4f..940474a 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -10,10 +10,10 @@ const messaging = new sdk.Messaging(client); const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', - content: '<CONTENT>', // optional topics: [], // optional users: [], // optional targets: [], // optional + content: '<CONTENT>', // optional draft: false, // optional scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional }); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 7a6f1a3..326620f 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -14,5 +14,8 @@ const result = await mongo.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mongo/promote-restoration.md b/docs/examples/mongo/promote-restoration.md new file mode 100644 index 0000000..dc19b5c --- /dev/null +++ b/docs/examples/mongo/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mongo = new sdk.Mongo(client); + +const result = await mongo.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index 6e95f01..9e4843c 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -14,5 +14,8 @@ const result = await mysql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/mysql/promote-restoration.md b/docs/examples/mysql/promote-restoration.md new file mode 100644 index 0000000..8aa43ed --- /dev/null +++ b/docs/examples/mysql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const mysql = new sdk.Mysql(client); + +const result = await mysql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 003c717..32320e9 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -20,7 +20,7 @@ const result = await oauth2.authorizePost({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index fe529c6..384e3bf 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -20,7 +20,7 @@ const result = await oauth2.authorize({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional requestUri: '<REQUEST_URI>', // optional }); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index e49bef1..4215069 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -12,7 +12,7 @@ const result = await oauth2.createDeviceAuthorization({ clientId: '<CLIENT_ID>', // optional scope: '<SCOPE>', // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index b579484..575b70e 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -20,7 +20,7 @@ const result = await oauth2.createPAR({ prompt: '<PROMPT>', // optional maxAge: 0, // optional authorizationDetails: '<AUTHORIZATION_DETAILS>', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index ea081d1..cb9ca65 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -17,7 +17,7 @@ const result = await oauth2.createToken({ clientSecret: '<CLIENT_SECRET>', // optional codeVerifier: '<CODE_VERIFIER>', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '<AUDIENCE>', // optional }); ``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index 5cc8ea0..9647966 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -14,5 +14,8 @@ const result = await postgresql.createRestoration({ backupId: '<BACKUP_ID>', // optional targetDatabaseId: '<TARGET_DATABASE_ID>', // optional targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '<TARGET_NAME>', // optional + autoPromote: false, // optional }); ``` diff --git a/docs/examples/postgresql/promote-restoration.md b/docs/examples/postgresql/promote-restoration.md new file mode 100644 index 0000000..48e87af --- /dev/null +++ b/docs/examples/postgresql/promote-restoration.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const postgresql = new sdk.Postgresql(client); + +const result = await postgresql.promoteRestoration({ + databaseId: '<DATABASE_ID>', + restorationId: '<RESTORATION_ID>', +}); +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 083eee1..8e0d6f7 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ const result = await project.createAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..c0add3b --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..5400831 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.deleteEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..417f5c8 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.getEnvironment({ + environmentId: '<ENVIRONMENT_ID>', +}); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..88d3d57 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.listEnvironments({ + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ad0d3d2..83d4d65 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ const result = await project.updateAndroidPlatform({ platformId: '<PLATFORM_ID>', name: '<NAME>', applicationId: '<APPLICATION_ID>', + fingerprints: [], // optional }); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..14bb9a8 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateEnvironment({ + environmentId: '<ENVIRONMENT_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 9319a90..e1392e0 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -13,8 +13,8 @@ const result = await project.updateOAuth2Apple({ keyId: '<KEY_ID>', // optional teamId: '<TEAM_ID>', // optional p8File: '<P8_FILE>', // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 61fb73c..79ba89d 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Auth0({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional endpoint: '<ENDPOINT>', // optional - prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2Auth0Prompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index d76ac95..a8d5282 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Discord({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2DiscordPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index cb497db..8d3fbdd 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2GitHub({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2GitHubPrompt.SelectAccount], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 0325eef..fc081aa 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -12,8 +12,8 @@ const result = await project.updateOAuth2Google({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional prompt: [sdk.ProjectOAuth2GooglePrompt.None], // optional - nativeClientIds: [], // optional enabled: false, // optional + nativeClientIds: [], // optional nativeEnabled: false, // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index cb310ae..af88267 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Kakao({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2KakaoPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7a7edb2..2cb3efe 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -12,7 +12,7 @@ const result = await project.updateOAuth2Microsoft({ applicationId: '<APPLICATION_ID>', // optional applicationSecret: '<APPLICATION_SECRET>', // optional tenant: '<TENANT>', // optional - prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2MicrosoftPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 4b6deba..7f0052b 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -13,7 +13,7 @@ const result = await project.updateOAuth2Okta({ clientSecret: '<CLIENT_SECRET>', // optional domain: 'example.com', // optional authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional - prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2OktaPrompt.None], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 12698d0..ffd57c0 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Salesforce({ customerKey: '<CUSTOMER_KEY>', // optional customerSecret: '<CUSTOMER_SECRET>', // optional - prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2SalesforcePrompt.Login], // optional }); ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index baa7bc8..2ccc10d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateOAuth2Zoho({ clientId: '<CLIENT_ID>', // optional clientSecret: '<CLIENT_SECRET>', // optional - prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional enabled: false, // optional + prompt: [sdk.ProjectOAuth2ZohoPrompt.Consent], // optional }); ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 0000000..c289240 --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasskeyPolicy({ + rpId: '<RP_ID>', +}); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..b6d281e --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updatePasswordRotationPolicy({ + enabled: false, // optional + maxAge: 86400, // optional +}); +``` diff --git a/docs/examples/proxy/create-smtp-rule.md b/docs/examples/proxy/create-smtp-rule.md new file mode 100644 index 0000000..28691f6 --- /dev/null +++ b/docs/examples/proxy/create-smtp-rule.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const proxy = new sdk.Proxy(client); + +const result = await proxy.createSMTPRule({ + domain: 'example.com', + functionId: '<FUNCTION_ID>', + branch: '<BRANCH>', // optional +}); +``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 47773fb..2d45ad5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ const result = await teams.createMembership({ phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional + membershipId: '<MEMBERSHIP_ID>', // optional }); ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 0000000..0a8b24b --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.deletePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 0000000..f4f8ac7 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,15 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.getPasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', +}); +``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md new file mode 100644 index 0000000..cd08eeb --- /dev/null +++ b/docs/examples/users/list-passkeys.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.listPasskeys({ + userId: '<USER_ID>', + queries: [], // optional + total: false, // optional +}); +``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 0000000..b6572ba --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const users = new sdk.Users(client); + +const result = await users.updatePasskey({ + userId: '<USER_ID>', + passkeyId: '<PASSKEY_ID>', + name: '<NAME>', +}); +``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..36ac236 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..8a52e55 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..2fd6fdc --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..d40cd0b --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,26 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + key: 'ip', // optional + strategy: 'fixedWindow', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..d606bc9 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.createRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', + name: '<NAME>', + location: '<LOCATION>', + statusCode: 300, + resourceId: '<RESOURCE_ID>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..3b08063 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.deleteRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..5d4bbe1 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.getRule({ + ruleId: '<RULE_ID>', +}); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..eef8e17 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,16 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.listRules({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false, // optional +}); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..9fa71c1 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateBypassRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..a5f85ba --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,24 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateChallengeRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + challengeType: 'compute', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional + difficulty: 1, // optional + ttl: 900, // optional +}); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..2764b4c --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,21 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateDenyRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..f7810bd --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,25 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRateLimitRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + limit: 1, // optional + interval: 1, // optional + key: 'ip', // optional + maxBucketSize: 1, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..7355421 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,23 @@ +```javascript +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setKey('<YOUR_API_KEY>'); // Your secret API key + +const waf = new sdk.Waf(client); + +const result = await waf.updateRedirectRule({ + ruleId: '<RULE_ID>', + resourceType: 'api', // optional + resourceId: '<RESOURCE_ID>', // optional + name: '<NAME>', // optional + description: '<DESCRIPTION>', // optional + location: '<LOCATION>', // optional + statusCode: 300, // optional + priority: -100000, // optional + enabled: false, // optional + conditions: [], // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 686fc2d..dc39f37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "30.0.0-rc.2", + "version": "30.0.1", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index e69605d..08ac31b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "30.0.0-rc.2", + "version": "30.0.1", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 393e2b4..70e8538 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { fetch, FormData, File, Agent, type RequestInit } from 'undici'; import { Models } from './models'; import { InputFile } from './inputFile'; +import { flattenParam } from './query'; import JSONbigModule from 'json-bigint'; const JSONbigParser = JSONbigModule({ storeAsString: false }); const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true }); @@ -44,6 +45,79 @@ const JSONbig = { stringify: JSONbigSerializer.stringify, }; +type DefaultsShape = string | { items: DefaultsShape }; + +type DefaultsModel = { + defaults?: Record<string, unknown>; + properties?: Record<string, DefaultsShape>; +}; + +type Defaults = { + root: DefaultsShape; + models: Record<string, DefaultsModel>; +}; + +export function applyDefaults<T>(value: T, tree: Defaults): T { + return fillDefaults(value, tree.root, tree.models) as T; +} + +function cloneDefault(value: unknown): unknown { + if (Array.isArray(value)) { + return value.map(cloneDefault); + } + if (typeof value === 'object' && value !== null) { + const copy: Record<string, unknown> = {}; + for (const [key, member] of Object.entries(value)) { + copy[key] = cloneDefault(member); + } + return copy; + } + return value; +} + +function fillDefaults( + value: unknown, + shape: DefaultsShape, + models: Record<string, DefaultsModel>, +): unknown { + if (typeof shape !== 'string') { + if (!Array.isArray(value)) { + return value; + } + const items = shape.items; + return value.map((item) => fillDefaults(item, items, models)); + } + const model = models[shape]; + if (!model || typeof value !== 'object' || value === null) { + return value; + } + if (Array.isArray(value)) { + return value; + } + const result: Record<string, unknown> = { ...model.defaults, ...value }; + // Each item gets its own copy of a filled-in list or object, so mutating one doesn't change the rest + for (const key of Object.keys(model.defaults ?? {})) { + if (!Object.prototype.hasOwnProperty.call(value, key)) { + result[key] = cloneDefault(result[key]); + } + } + for (const [key, child] of Object.entries(model.properties ?? {})) { + if (key in result) { + result[key] = fillDefaults(result[key], child, models); + } + } + // The spread drops the non-enumerable JSON toString that Client.call attaches. + if (Object.prototype.hasOwnProperty.call(value, 'toString')) { + Object.defineProperty(result, 'toString', { + value: () => JSONbig.stringify(result), + writable: true, + enumerable: false, + configurable: true, + }); + } + return result; +} + type Payload = { [key: string]: any; }; @@ -80,7 +154,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/30.0.0-rc.2'; + let ua = 'AppwriteNodeJSSDK/30.0.1'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -141,9 +215,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '30.0.0-rc.2', + 'x-sdk-version': '30.0.1', 'user-agent': getUserAgent(), - 'X-Appwrite-Response-Format': '2.3.0', + 'X-Appwrite-Response-Format': '2.5.0', }; /** @@ -394,6 +468,10 @@ class Client { ): { uri: string; options: RequestInit } { method = method.toUpperCase(); + for (const key of Object.keys(params)) { + params[key] = flattenParam(params[key]); + } + headers = Object.assign({}, this.headers, headers); const options: RequestInit = { @@ -887,6 +965,6 @@ class Client { } export { Client, AppwriteException }; -export { Query } from './query'; +export { Query, QueryBuilder, flattenParam } from './query'; export type { Models, Payload, UploadProgress }; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts index e849833..275668e 100644 --- a/src/enums/databases-index-type.ts +++ b/src/enums/databases-index-type.ts @@ -3,4 +3,5 @@ export enum DatabasesIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/execution-trigger.ts b/src/enums/execution-trigger.ts index 84fa8f6..b16a878 100644 --- a/src/enums/execution-trigger.ts +++ b/src/enums/execution-trigger.ts @@ -2,4 +2,5 @@ export enum ExecutionTrigger { Http = 'http', Schedule = 'schedule', Event = 'event', + Email = 'email', } diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts index 367ed14..34504b4 100644 --- a/src/enums/project-auth-method-id.ts +++ b/src/enums/project-auth-method-id.ts @@ -6,4 +6,5 @@ export enum ProjectAuthMethodId { Invites = 'invites', Jwt = 'jwt', Phone = 'phone', + Passkey = 'passkey', } diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts index 48ab459..3cb8cc4 100644 --- a/src/enums/project-key-scopes.ts +++ b/src/enums/project-key-scopes.ts @@ -122,4 +122,6 @@ export enum ProjectKeyScopes { Oauth2Read = 'oauth2.read', Oauth2Write = 'oauth2.write', Oauth2Introspect = 'oauth2.introspect', + AnalyticsRead = 'analytics.read', + AnalyticsWrite = 'analytics.write', } diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts index d323094..67fc5fe 100644 --- a/src/enums/project-policy-id.ts +++ b/src/enums/project-policy-id.ts @@ -4,6 +4,7 @@ export enum ProjectPolicyId { Passwordstrength = 'password-strength', Passwordpersonaldata = 'password-personal-data', Passwordpwned = 'password-pwned', + Passwordrotation = 'password-rotation', Sessionalert = 'session-alert', Sessionduration = 'session-duration', Sessioninvalidation = 'session-invalidation', @@ -15,4 +16,5 @@ export enum ProjectPolicyId { Denydisposableemail = 'deny-disposable-email', Denyfreeemail = 'deny-free-email', Denycorporateemail = 'deny-corporate-email', + Passkey = 'passkey', } diff --git a/src/enums/proxy-rule-protocol.ts b/src/enums/proxy-rule-protocol.ts new file mode 100644 index 0000000..1ed23de --- /dev/null +++ b/src/enums/proxy-rule-protocol.ts @@ -0,0 +1,4 @@ +export enum ProxyRuleProtocol { + Http = 'http', + Smtp = 'smtp', +} diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts index 246bfc4..09fd95c 100644 --- a/src/enums/tables-db-index-type.ts +++ b/src/enums/tables-db-index-type.ts @@ -3,4 +3,5 @@ export enum TablesDBIndexType { Fulltext = 'fulltext', Unique = 'unique', Spatial = 'spatial', + Trigram = 'trigram', } diff --git a/src/enums/waf-rule-action.ts b/src/enums/waf-rule-action.ts new file mode 100644 index 0000000..38534a9 --- /dev/null +++ b/src/enums/waf-rule-action.ts @@ -0,0 +1,7 @@ +export enum WafRuleAction { + Bypass = 'bypass', + Deny = 'deny', + Challenge = 'challenge', + RateLimit = 'rateLimit', + Redirect = 'redirect', +} diff --git a/src/index.ts b/src/index.ts index 3042486..e0da2f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,10 @@ -export { Client, Query, AppwriteException } from './client'; +export { + Client, + Query, + QueryBuilder, + flattenParam, + AppwriteException, +} from './client'; export { Account } from './services/account'; export { Activities } from './services/activities'; export { Apps } from './services/apps'; @@ -28,13 +34,14 @@ export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; export { Users } from './services/users'; export { VectorsDB } from './services/vectors-db'; +export { Waf } from './services/waf'; export { Webhooks } from './services/webhooks'; export type { Models, Payload, UploadProgress } from './client'; -export type { QueryTypes, QueryTypesList } from './query'; +export type { QueryTypes, QueryTypesList, QueryInput } from './query'; export { Permission } from './permission'; export { Role } from './role'; export { ID } from './id'; -export { Topic, ResolvedTopic } from './topic'; +export { Topic } from './topic'; export { Operator, Condition } from './operator'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; @@ -116,6 +123,8 @@ export { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; export { PlatformType } from './enums/platform-type'; export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; export { ProxyRuleStatus } from './enums/proxy-rule-status'; +export { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; export { MessageStatus } from './enums/message-status'; export { BillingPlanGroup } from './enums/billing-plan-group'; export { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +export { WafRuleAction } from './enums/waf-rule-action'; diff --git a/src/models.ts b/src/models.ts index 1fac7bc..afb50ff 100644 --- a/src/models.ts +++ b/src/models.ts @@ -22,9 +22,11 @@ import { OAuth2KakaoPrompt } from './enums/o-auth-2-kakao-prompt'; import { PlatformType } from './enums/platform-type'; import { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; import { ProxyRuleStatus } from './enums/proxy-rule-status'; +import { ProxyRuleProtocol } from './enums/proxy-rule-protocol'; import { MessageStatus } from './enums/message-status'; import { BillingPlanGroup } from './enums/billing-plan-group'; import { DomainTransferStatusEnum } from './enums/domain-transfer-status-enum'; +import { WafRuleAction } from './enums/waf-rule-action'; /** * Appwrite Models @@ -503,6 +505,7 @@ export namespace Models { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -514,6 +517,7 @@ export namespace Models { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey )[]; }; @@ -744,39 +748,39 @@ export namespace Models { /** * Dedicated database lifecycle status. Null when the database has no valid dedicated backing. */ - status?: DatabaseStatus; + status?: DatabaseStatus | null; /** * Underlying engine of the dedicated backing: postgresql, mysql, or mongodb. A managed product (tablesdb, documentsdb, vectorsdb) reports the engine it runs on, so its type and engine can differ. Null when the database has no dedicated backing. */ - engine?: string; + engine?: string | null; /** * Compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. Null when the database has no dedicated backing. */ - specification?: string; + specification?: string | null; /** * Number of secondary high availability replicas, excluding the primary. Null when backing configuration is unavailable. */ - replicas?: number; + replicas?: number | null; /** * Error message when the dedicated backing failed. Null when the database has no dedicated backing or has not failed. */ - error?: string; + error?: string | null; /** * Container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). Null when the database has no dedicated backing or the runtime has not reported one. */ - containerStatus?: string; + containerStatus?: string | null; /** * 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; + lifecycleState?: string | null; /** * Database backup policies. */ - policies?: BackupPolicy[]; + policies?: BackupPolicy[] | null; /** * Database backup archives. */ - archives?: BackupArchive[]; + archives?: BackupArchive[] | null; }; /** @@ -934,7 +938,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -950,11 +954,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -984,7 +988,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -996,15 +1000,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1034,7 +1038,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1046,15 +1050,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -1084,7 +1088,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1096,15 +1100,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number; + default?: number | null; }; /** @@ -1134,7 +1138,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1146,7 +1150,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -1176,7 +1180,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1192,7 +1196,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1222,7 +1226,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1242,7 +1246,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1272,7 +1276,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1288,7 +1292,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1318,7 +1322,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1334,7 +1338,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; }; /** @@ -1364,7 +1368,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1380,7 +1384,7 @@ export namespace Models { /** * Default value for attribute when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -1410,7 +1414,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1472,7 +1476,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1484,7 +1488,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -1514,7 +1518,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1526,7 +1530,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -1556,7 +1560,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1568,7 +1572,7 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -1598,7 +1602,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1614,11 +1618,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1648,7 +1652,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1660,11 +1664,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1694,7 +1698,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1706,11 +1710,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1740,7 +1744,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1752,11 +1756,11 @@ export namespace Models { /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ - default?: string; + default?: string | null; /** * Defines whether this attribute is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -1844,7 +1848,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -1882,7 +1886,7 @@ export namespace Models { /** * Is attribute an array? */ - array?: boolean; + array?: boolean | null; /** * Attribute creation date in ISO 8601 format. */ @@ -2030,7 +2034,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2046,11 +2050,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2080,7 +2084,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2092,15 +2096,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2130,7 +2134,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2142,15 +2146,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number | bigint; + min?: number | bigint | null; /** * Maximum value to enforce for new documents. */ - max?: number | bigint; + max?: number | bigint | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number | bigint; + default?: number | bigint | null; }; /** @@ -2180,7 +2184,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2192,15 +2196,15 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | null; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | null; /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number; + default?: number | null; }; /** @@ -2230,7 +2234,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2242,7 +2246,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: boolean; + default?: boolean | null; }; /** @@ -2272,7 +2276,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2288,7 +2292,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2318,7 +2322,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2338,7 +2342,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2368,7 +2372,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2384,7 +2388,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2414,7 +2418,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2430,7 +2434,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; }; /** @@ -2460,7 +2464,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2476,7 +2480,7 @@ export namespace Models { /** * Default value for column when not provided. Only null is optional */ - default?: string; + default?: string | null; }; /** @@ -2506,7 +2510,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2568,7 +2572,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2580,7 +2584,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[]; + default?: number[] | null; }; /** @@ -2610,7 +2614,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2622,7 +2626,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][]; + default?: number[][] | null; }; /** @@ -2652,7 +2656,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2664,7 +2668,7 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: number[][][]; + default?: number[][][] | null; }; /** @@ -2694,7 +2698,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2710,11 +2714,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2744,7 +2748,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2756,11 +2760,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2790,7 +2794,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2802,11 +2806,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2836,7 +2840,7 @@ export namespace Models { /** * Is column an array? */ - array?: boolean; + array?: boolean | null; /** * Column creation date in ISO 8601 format. */ @@ -2848,11 +2852,11 @@ export namespace Models { /** * Default value for column when not provided. Cannot be set when column is required. */ - default?: string; + default?: string | null; /** * Defines whether this column is encrypted or not. */ - encrypt?: boolean; + encrypt?: boolean | null; }; /** @@ -2898,7 +2902,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -2944,7 +2948,7 @@ export namespace Models { /** * Index orders. */ - orders?: string[]; + orders?: string[] | null; }; /** @@ -3052,7 +3056,7 @@ export namespace Models { /** * Presence status. */ - status?: string; + status?: string | null; /** * Presence source. */ @@ -3060,7 +3064,7 @@ export namespace Models { /** * Presence expiry date in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * Presence metadata. */ @@ -3092,15 +3096,15 @@ export namespace Models { /** * Hashed user password. */ - password?: string; + password?: string | null; /** * Password hashing algorithm. */ - hash?: string; + hash?: string | null; /** * Password hashing algorithm configuration. */ - hashOptions?: object; + hashOptions?: object | null; /** * User registration date in ISO 8601 format. */ @@ -3132,27 +3136,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3176,11 +3180,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3346,27 +3350,27 @@ export namespace Models { /** * Canonical form of the user email address. */ - emailCanonical?: string; + emailCanonical?: string | null; /** * Whether the user email is from a free email provider. */ - emailIsFree?: boolean; + emailIsFree?: boolean | null; /** * Whether the user email is from a disposable email provider. */ - emailIsDisposable?: boolean; + emailIsDisposable?: boolean | null; /** * Whether the user email is from a corporate domain. */ - emailIsCorporate?: boolean; + emailIsCorporate?: boolean | null; /** * Whether the user email is in its canonical form. */ - emailIsCanonical?: boolean; + emailIsCanonical?: boolean | null; /** * Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. */ - passwordPwned?: boolean; + passwordPwned?: boolean | null; /** * Phone verification status. */ @@ -3390,11 +3394,11 @@ export namespace Models { /** * Whether the user can impersonate other users. */ - impersonator?: boolean; + impersonator?: boolean | null; /** * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. */ - impersonatorUserId?: string; + impersonatorUserId?: string | null; }; /** @@ -3654,47 +3658,47 @@ export namespace Models { /** * City */ - city?: string; + city?: string | null; /** * Name of timezone */ - timeZone?: string; + timeZone?: string | null; /** * Postal code */ - postalCode?: string; + postalCode?: string | null; /** * Latitude */ - latitude?: number; + latitude?: number | null; /** * Longitude */ - longitude?: number; + longitude?: number | null; /** * Autonomous System Number (ASN) of the IP */ - autonomousSystemNumber?: string; + autonomousSystemNumber?: string | null; /** * Organization that owns the ASN */ - autonomousSystemOrganization?: string; + autonomousSystemOrganization?: string | null; /** * Internet service provider of the IP */ - isp?: string; + isp?: string | null; /** * Connection type of the IP (e.g. cable, cellular, corporate) */ - connectionType?: string; + connectionType?: string | null; /** * User type classification of the IP (e.g. residential, business, hosting) */ - connectionUsageType?: string; + connectionUsageType?: string | null; /** * Registered organization of the IP */ - connectionOrganization?: string; + connectionOrganization?: string | null; }; /** @@ -4201,6 +4205,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number | null; /** * Function execution timeout in seconds. */ @@ -4253,6 +4261,10 @@ export namespace Models { * Machine specification for executions. */ runtimeSpecification: string; + /** + * Whether inbound email (SMTP) may trigger this function. Opt-in; default is false. When disabled, recipients for this function are rejected. + */ + emailEnabled: boolean; }; /** @@ -4342,7 +4354,7 @@ export namespace Models { /** * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. */ - fallbackFile?: string; + fallbackFile?: string | null; }; /** @@ -4492,7 +4504,7 @@ export namespace Models { */ deploymentId: string; /** - * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. + * The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, `event`, or `email`. */ trigger: ExecutionTrigger; /** @@ -4538,7 +4550,7 @@ export namespace Models { /** * The scheduled time for execution. If left empty, execution will be queued immediately. */ - scheduledAt?: string; + scheduledAt?: string | null; }; /** @@ -4652,87 +4664,91 @@ export namespace Models { /** * Whether WAF enforcement is enabled for the project. */ - wafEnabled?: boolean; + wafEnabled?: boolean | null; + /** + * ID of the project this environment belongs to. Null when the project is not an environment. + */ + parentId?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * First time the project received a non-console API request. Empty until the project is used. */ - firstAccessedAt?: string; + firstAccessedAt?: string | null; /** * Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. */ - mcpAccessedAt?: string; + mcpAccessedAt?: string | null; /** * OAuth2 server status */ - oAuth2ServerEnabled?: boolean; + oAuth2ServerEnabled?: boolean | null; /** * OAuth2 server authorization URL */ - oAuth2ServerAuthorizationUrl?: string; + oAuth2ServerAuthorizationUrl?: string | null; /** * OAuth2 server allowed scopes */ - oAuth2ServerScopes?: string[]; + oAuth2ServerScopes?: string[] | null; /** * OAuth2 server scopes used when an authorization request omits the scope parameter */ - oAuth2ServerDefaultScopes?: string[]; + oAuth2ServerDefaultScopes?: string[] | null; /** * Scopes an application may request when installed on a team */ - oAuth2ServerInstallationScopes?: string[]; + oAuth2ServerInstallationScopes?: string[] | null; /** * OAuth2 server accepted RFC 9396 authorization_details types */ - oAuth2ServerAuthorizationDetailsTypes?: string[]; + oAuth2ServerAuthorizationDetailsTypes?: string[] | null; /** * OAuth2 server access token duration in seconds for confidential clients */ - oAuth2ServerAccessTokenDuration?: number; + oAuth2ServerAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for confidential clients */ - oAuth2ServerRefreshTokenDuration?: number; + oAuth2ServerRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicAccessTokenDuration?: number; + oAuth2ServerPublicAccessTokenDuration?: number | null; /** * OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native) */ - oAuth2ServerPublicRefreshTokenDuration?: number; + oAuth2ServerPublicRefreshTokenDuration?: number | null; /** * OAuth2 server access token duration in seconds for app installation access tokens */ - oAuth2ServerInstallationAccessTokenDuration?: number; + oAuth2ServerInstallationAccessTokenDuration?: number | null; /** * When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. */ - oAuth2ServerConfidentialPkce?: boolean; + oAuth2ServerConfidentialPkce?: boolean | null; /** * URL to your application page where users enter the device flow user code. Empty when the Device Authorization Grant is not configured. */ - oAuth2ServerVerificationUrl?: string; + oAuth2ServerVerificationUrl?: string | null; /** * Number of characters in the device flow user code, excluding the formatting separator. */ - oAuth2ServerUserCodeLength?: number; + oAuth2ServerUserCodeLength?: number | null; /** * Character set for device flow user codes: `numeric`, `alphabetic`, or `alphanumeric`. */ - oAuth2ServerUserCodeFormat?: string; + oAuth2ServerUserCodeFormat?: string | null; /** * Lifetime in seconds of device flow device codes and user codes. */ - oAuth2ServerDeviceCodeDuration?: number; + oAuth2ServerDeviceCodeDuration?: number | null; /** * OAuth2 server discovery URL */ - oAuth2ServerDiscoveryUrl?: string; + oAuth2ServerDiscoveryUrl?: string | null; }; /** @@ -5898,7 +5914,7 @@ export namespace Models { /** * Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds. */ - maxAge?: number; + maxAge?: number | null; }; /** @@ -6251,6 +6267,24 @@ export namespace Models { users: boolean; }; + /** + * Policy Password Rotation + */ + export type PolicyPasswordRotation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether expired passwords require a reset before email/password sign-in. + */ + enabled: boolean; + /** + * Maximum password age in seconds. + */ + maxAge: number; + }; + /** * Policy Session Alert */ @@ -6381,6 +6415,24 @@ export namespace Models { custom: boolean; }; + /** + * Policy Passkey + */ + export type PolicyPasskey = { + /** + * Policy ID. + */ + $id: string; + /** + * Relying party ID passkeys are bound to. Empty until configured. + */ + rpId: string; + /** + * Web origins passkeys work on, from the project's platforms on the relying party ID and a localhost web platform. Read-only. + */ + origins: string[]; + }; + /** * Policy Deny Aliased Email */ @@ -6525,6 +6577,10 @@ export namespace Models { * Android application ID. */ applicationId: string; + /** + * SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + */ + fingerprints: string[]; }; /** @@ -6822,7 +6878,7 @@ export namespace Models { /** * Type of deployment resource: function, site, or dedicatedDatabase. */ - deploymentResourceType?: ProxyRuleDeploymentResourceType; + deploymentResourceType?: ProxyRuleDeploymentResourceType | null; /** * ID of deployment's resource (site or function ID). Used if type is "deployment" */ @@ -6843,6 +6899,10 @@ export namespace Models { * Certificate auto-renewal date in ISO 8601 format. */ renewAt: string; + /** + * Ingress protocol for the rule. + */ + protocol: ProxyRuleProtocol; }; /** @@ -6931,6 +6991,102 @@ export namespace Models { code: string; }; + /** + * Token Secret + */ + export type TokenSecret = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. Exchange it for a session with the create session endpoint. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * 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; + }; + + /** + * Passkey + */ + export type Passkey = { + /** + * Passkey ID. + */ + $id: string; + /** + * Passkey creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Passkey update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Passkey name. + */ + name: string; + /** + * Most recent sign-in with this passkey in ISO 8601 format. Empty until the passkey is used to sign in. + */ + accessedAt: string; + }; + + /** + * Passkey Challenge + */ + export type PasskeyChallenge = { + /** + * Challenge ID. When signing in, pass it back with the credential to receive a token. + */ + $id: string; + /** + * Challenge creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * ID of the passkey being registered. Empty for sign-in challenges. + */ + passkeyId: string; + /** + * Challenge expiration date in ISO 8601 format. + */ + expire: string; + /** + * WebAuthn options in JSON form. Pass them to `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. + */ + publicKey: object; + }; + + /** + * Passkeys List + */ + export type PasskeyList = { + /** + * Total number of passkeys that matched your query. + */ + total: number; + /** + * List of passkeys. + */ + passkeys: Passkey[]; + }; + /** * MFA Recovery Codes */ @@ -7058,15 +7214,15 @@ export namespace Models { /** * The scheduled time for message. */ - scheduledAt?: string; + scheduledAt?: string | null; /** * The time when the message was delivered. */ - deliveredAt?: string; + deliveredAt?: string | null; /** * Delivery errors if any. */ - deliveryErrors?: string[]; + deliveryErrors?: string[] | null; /** * Number of recipients the message was delivered to. */ @@ -7120,11 +7276,11 @@ export namespace Models { /** * MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. */ - qos?: number; + qos?: number | null; /** - * Message retention in seconds for offline delivery. + * Message retention in seconds for offline delivery. Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. */ - expiry?: number; + expiry?: number | null; }; /** @@ -7226,7 +7382,7 @@ export namespace Models { /** * Provider ID. */ - providerId?: string; + providerId?: string | null; /** * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ @@ -7304,15 +7460,15 @@ export namespace Models { /** * Time the insight was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; /** * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - dismissedAt?: string; + dismissedAt?: string | null; /** * User ID that dismissed the insight. Empty when not dismissed. */ - dismissedBy?: string; + dismissedBy?: string | null; }; /** @@ -7388,7 +7544,7 @@ export namespace Models { /** * Time the report was analyzed in ISO 8601 format. */ - analyzedAt?: string; + analyzedAt?: string | null; }; /** @@ -7566,7 +7722,7 @@ export namespace Models { /** * Archive size in bytes. Null until the size is known. */ - size?: number; + size?: number | null; /** * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ @@ -7574,7 +7730,7 @@ export namespace Models { /** * The backup start time. Null until the backup starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -7590,11 +7746,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this archive should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this archive should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; }; /** @@ -7648,23 +7804,23 @@ export namespace Models { /** * Backup start time in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Backup completion time in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Backup verification time in ISO 8601 format. */ - verifiedAt?: string; + verifiedAt?: string | null; /** * Backup expiration time in ISO 8601 format. */ - expiresAt?: string; + expiresAt?: string | null; /** * 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; + logPosition?: string | null; /** * Error message if backup failed. */ @@ -7718,35 +7874,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth?: number; + bandwidth?: number | null; /** * Storage limit */ - storage?: number; + storage?: number | null; /** * Users limit */ - users?: number; + users?: number | null; /** * Executions limit */ - executions?: number; + executions?: number | null; /** * GBHours limit */ - GBHours?: number; + GBHours?: number | null; /** * Image transformations limit */ - imageTransformations?: number; + imageTransformations?: number | null; /** * Auth phone limit */ - authPhone?: number; + authPhone?: number | null; /** * Budget limit percentage */ - budgetLimit?: number; + budgetLimit?: number | null; }; /** @@ -7796,7 +7952,7 @@ export namespace Models { /** * Members */ - members?: number; + members?: number | null; /** * Webhooks */ @@ -7805,6 +7961,10 @@ export namespace Models { * Maximum WAF rules per project */ wafRules: number; + /** + * Maximum environments per project. 0 when the plan does not offer environments. + */ + environments: number; /** * Projects */ @@ -7892,7 +8052,7 @@ export namespace Models { /** * Activity log days */ - activityLogs?: number; + activityLogs?: number | null; /** * Usage history days */ @@ -7900,11 +8060,11 @@ export namespace Models { /** * Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). */ - usageLogsIntervals?: string[]; + usageLogsIntervals?: string[] | null; /** * Metrics this plan only records as a total. They cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. */ - usageAggregateOnlyMetrics?: string[]; + usageAggregateOnlyMetrics?: string[] | null; /** * Number of days of console inactivity before a project is paused. 0 means pausing is disabled. */ @@ -7916,7 +8076,7 @@ export namespace Models { /** * Additional resources. Null when the plan does not support usage billing. */ - usage?: UsageBillingPlan; + usage?: UsageBillingPlan | null; /** * Addons */ @@ -7944,7 +8104,7 @@ export namespace Models { /** * ISO country codes eligible for this regional plan. Empty means no restriction. */ - eligibleCountries?: string[]; + eligibleCountries?: string[] | null; /** * Is the billing plan available */ @@ -8000,7 +8160,7 @@ export namespace Models { /** * Does plan support backup policies. */ - backupsEnabled?: boolean; + backupsEnabled?: boolean | null; /** * Whether usage addons are calculated per project. */ @@ -8012,7 +8172,7 @@ export namespace Models { /** * How many policies does plan support */ - backupPolicies?: number; + backupPolicies?: number | null; /** * Maximum function and site deployment size in MB */ @@ -8021,6 +8181,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ @@ -8028,7 +8192,7 @@ export namespace Models { /** * Plan specific limits */ - limits?: BillingPlanLimits; + limits?: BillingPlanLimits | null; /** * Group of this billing plan for variants */ @@ -8036,7 +8200,7 @@ export namespace Models { /** * Details of the program this plan is a part of. */ - program?: Program; + program?: Program | null; /** * Included monthly dedicated-database compute credit in USD. Resets each billing cycle with no roll-over. */ @@ -8044,7 +8208,7 @@ export namespace Models { /** * Dedicated database limits available to this plan. */ - dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits; + dedicatedDatabases?: BillingPlanDedicatedDatabaseLimits | null; }; /** @@ -8054,11 +8218,11 @@ export namespace Models { /** * Addon seats */ - seats?: BillingPlanAddonDetails; + seats?: BillingPlanAddonDetails | null; /** * Addon projects */ - projects?: BillingPlanAddonDetails; + projects?: BillingPlanAddonDetails | null; }; /** @@ -8084,7 +8248,7 @@ export namespace Models { /** * Price currency */ - currency?: string; + currency?: string | null; /** * Price */ @@ -8106,11 +8270,11 @@ export namespace Models { /** * Credits limit per billing cycle */ - credits?: number; + credits?: number | null; /** * Daily credits limit (if applicable) */ - dailyCredits?: number; + dailyCredits?: number | null; }; /** @@ -8120,79 +8284,79 @@ export namespace Models { /** * Minimum CPU allocation in millicores. */ - minCpu?: number; + minCpu?: number | null; /** * Maximum CPU allocation in millicores. */ - maxCpu?: number; + maxCpu?: number | null; /** * Minimum memory allocation in megabytes. */ - minMemoryMb?: number; + minMemoryMb?: number | null; /** * Maximum memory allocation in megabytes. */ - maxMemoryMb?: number; + maxMemoryMb?: number | null; /** * Minimum storage allocation in gigabytes. */ - minStorageGb?: number; + minStorageGb?: number | null; /** * Maximum storage allocation in gigabytes. */ - maxStorageGb?: number; + maxStorageGb?: number | null; /** * Maximum number of high-availability replicas per dedicated database. */ - maxReplicas?: number; + maxReplicas?: number | null; /** * Maximum number of client connections. */ - maxConnections?: number; + maxConnections?: number | null; /** * Maximum number of entries allowed in the IP allowlist. */ - maxIpAllowlistSize?: number; + maxIpAllowlistSize?: number | null; /** * Maximum number of database extensions that can be enabled. */ - maxExtensions?: number; + maxExtensions?: number | null; /** * Maximum number of days a backup can be retained. */ - maxBackupRetentionDays?: number; + maxBackupRetentionDays?: number | null; /** * Maximum number of days of point-in-time recovery data that can be retained. */ - maxPitrRetentionDays?: number; + maxPitrRetentionDays?: number | null; /** * Maximum number of rows a single SQL API query can return. */ - maxSqlApiMaxRows?: number; + maxSqlApiMaxRows?: number | null; /** * Maximum response size in bytes for a single SQL API query. */ - maxSqlApiMaxBytes?: number; + maxSqlApiMaxBytes?: number | null; /** * Maximum execution time in seconds for a single SQL API query. */ - maxSqlApiTimeoutSeconds?: number; + maxSqlApiTimeoutSeconds?: number | null; /** * Maximum number of SQL statement types that can be permitted through the SQL API. */ - maxSqlApiAllowedStatements?: number; + maxSqlApiAllowedStatements?: number | null; /** * SQL statement types permitted through the SQL API. */ - allowedSqlStatements?: string[]; + allowedSqlStatements?: string[] | null; /** * Storage classes available for dedicated databases. */ - allowedStorageClasses?: string[]; + allowedStorageClasses?: string[] | null; /** * Replica synchronization modes available for dedicated databases. */ - allowedSyncModes?: string[]; + allowedSyncModes?: string[] | null; }; /** @@ -8236,7 +8400,7 @@ export namespace Models { /** * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - expiredAt?: string; + expiredAt?: string | null; }; /** @@ -8266,7 +8430,7 @@ export namespace Models { /** * Branch port. Null until the backing reports one. */ - port: number; + port?: number | null; /** * Advertised catalog the client connects to. MySQL/MariaDB use default; Postgres uses the routing label. */ @@ -8408,11 +8572,11 @@ export namespace Models { /** * Product API that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. */ - api: string; + api?: string | null; /** * Database engine: postgresql, mysql, or mongodb. Null until the backing reports one. */ - engine: string; + engine?: string | null; /** * Database engine version. */ @@ -8432,7 +8596,7 @@ export namespace Models { /** * Database port for connections. Derived from the engine when the backing has not reported one yet. */ - connectionPort: number; + connectionPort?: number | null; /** * Database username for connections. */ @@ -8444,7 +8608,7 @@ export namespace Models { /** * Committed generation of the primary connection credentials. Null until the rotation contract has been initialized. */ - credentialGeneration: number; + credentialGeneration?: number | null; /** * Full database connection string (URI format). */ @@ -8464,11 +8628,11 @@ export namespace Models { /** * Last activity timestamp in ISO 8601 format. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; /** * Display-only timestamp when the database is expected to be considered idle (ISO 8601 format). Derived from last activity; lifecycle transitions are driven by lifecycleState. */ - idleUntil?: string; + idleUntil?: string | null; /** * Idle-lifecycle state of the database. Possible values: active, warm, cold, hibernated. */ @@ -8500,7 +8664,7 @@ export namespace Models { /** * Time the in-flight storage resize started, in ISO 8601 format. */ - storageResizeStartedAt?: string; + storageResizeStartedAt?: string | null; /** * Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. */ @@ -8658,7 +8822,7 @@ export namespace Models { /** * Source database ID when restoring a backup into another database. */ - sourceDatabaseId: string; + sourceDatabaseId?: string | null; /** * Project ID. */ @@ -8666,11 +8830,15 @@ export namespace Models { /** * Backup ID used for restoration (null for PITR). */ - backupId: string; + backupId?: string | null; /** * Restoration type. Possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). */ type: string; + /** + * Where the backup was restored. Possible values: in_place (replayed over the database that took the backup), clone (recovered onto a second workload beside the database, which keeps serving until the clone is promoted onto its endpoint), copy (recovered onto a separate database with its own endpoint). + */ + restoreMode: string; /** * Restoration status. Possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). */ @@ -8678,15 +8846,15 @@ export namespace Models { /** * Target time for PITR restoration in ISO 8601 format. */ - targetTime: string; + targetTime?: string | null; /** * Restoration start time in ISO 8601 format. */ - startedAt: string; + startedAt?: string | null; /** * Restoration completion time in ISO 8601 format. */ - completedAt: string; + completedAt?: string | null; /** * Error message if restoration failed. */ @@ -8720,7 +8888,7 @@ export namespace Models { /** * Connection statistics. Null when the database has not been probed. */ - connections?: DatabaseStatusConnections; + connections?: DatabaseStatusConnections | null; /** * Requested replication sync mode. Possible values: async, sync, quorum. Compare with effectiveSyncMode for what the primary is enforcing. */ @@ -8728,7 +8896,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -8744,7 +8912,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * List of database replicas and their status. Every configured member appears, including one the backend has not brought up, which is reported as not healthy. */ @@ -8856,7 +9024,7 @@ export namespace Models { /** * Transfer status for domains being transferred in. Null when the domain is not being transferred. */ - transferStatus?: DomainTransferStatusEnum; + transferStatus?: DomainTransferStatusEnum | null; /** * Team ID. */ @@ -8886,7 +9054,7 @@ export namespace Models { /** * Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. */ - price?: number; + price?: number | null; /** * Price period in years. */ @@ -8898,7 +9066,7 @@ export namespace Models { /** * Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. */ - renewalPrice?: number; + renewalPrice?: number | null; /** * Renewal price period in years. */ @@ -8960,11 +9128,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -8998,15 +9166,15 @@ export namespace Models { /** * Time the operation was requested, in ISO 8601 format. */ - requestedAt?: string; + requestedAt?: string | null; /** * Time the operation started, in ISO 8601 format. */ - startedAt?: string; + startedAt?: string | null; /** * Time the operation reached a terminal state, in ISO 8601 format. */ - completedAt?: string; + completedAt?: string | null; /** * Machine-readable failure code. `Interrupted` marks an attempt that ended before its outcome could be confirmed. */ @@ -9046,7 +9214,7 @@ export namespace Models { /** * Replication sync mode the primary is actually enforcing. Null when high availability is disabled or the state could not be read. A value below the requested syncMode means writes are being acknowledged with weaker durability than configured. */ - effectiveSyncMode?: string; + effectiveSyncMode?: string | null; /** * Whether the enforced replication is weaker than the requested syncMode. */ @@ -9062,7 +9230,7 @@ export namespace Models { /** * Whether the other sync fields are an engine reading rather than a recorded estimate. True when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. False when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. Absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. False never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ - syncStateConfirmed?: boolean; + syncStateConfirmed?: boolean | null; /** * Per-pod statuses for the primary and every replica. */ @@ -9124,7 +9292,7 @@ export namespace Models { /** * Project budget limit. Null when no budget is set. */ - billingBudget?: number; + billingBudget?: number | null; /** * Project budget limit */ @@ -9148,43 +9316,43 @@ export namespace Models { /** * Billing cycle start date. */ - billingStartDate: string; + billingStartDate?: string | null; /** * Current invoice cycle start date. */ - billingCurrentInvoiceDate: string; + billingCurrentInvoiceDate?: string | null; /** * Next invoice cycle start date. */ - billingNextInvoiceDate: string; + billingNextInvoiceDate?: string | null; /** * Start date of trial. */ - billingTrialStartDate?: string; + billingTrialStartDate?: string | null; /** * Number of trial days. */ - billingTrialDays: number; + billingTrialDays?: number | null; /** * Current active aggregation id. */ - billingAggregationId: string; + billingAggregationId?: string | null; /** * Current active aggregation id. */ - billingInvoiceId: string; + billingInvoiceId?: string | null; /** * Default payment method. */ - paymentMethodId: string; + paymentMethodId?: string | null; /** * Default payment method. */ - billingAddressId?: string; + billingAddressId?: string | null; /** * Backup payment method. */ - backupPaymentMethodId?: string; + backupPaymentMethodId?: string | null; /** * Team status. */ @@ -9192,39 +9360,39 @@ export namespace Models { /** * Remarks on team status. */ - remarks?: string; + remarks?: string | null; /** * Organization agreements */ - agreementBAA?: string; + agreementBAA?: string | null; /** * Program manager's name. */ - programManagerName?: string; + programManagerName?: string | null; /** * Program manager's calendar link. */ - programManagerCalendar?: string; + programManagerCalendar?: string | null; /** * Program's discord channel name. */ - programDiscordChannelName?: string; + programDiscordChannelName?: string | null; /** * Program's discord channel URL. */ - programDiscordChannelUrl?: string; + programDiscordChannelUrl?: string | null; /** * Billing limits reached */ - billingLimits?: BillingLimits; + billingLimits?: BillingLimits | null; /** * Billing plan selected for downgrade. */ - billingPlanDowngrade?: string; + billingPlanDowngrade?: string | null; /** * Tax Id */ - billingTaxId?: string; + billingTaxId?: string | null; /** * Marked for deletion */ @@ -9284,11 +9452,11 @@ export namespace Models { /** * The resource ID to backup. Set only if this policy should backup a single resource. */ - resourceId?: string; + resourceId?: string | null; /** * The resource type to backup. Set only if this policy should backup a single resource. */ - resourceType?: string; + resourceType?: string | null; /** * How many days to keep the backup before it will be automatically deleted. */ @@ -9448,7 +9616,7 @@ export namespace Models { /** * The restoration start time. Null until the restoration starts. */ - startedAt?: string; + startedAt?: string | null; /** * Migration ID. */ @@ -9586,11 +9754,11 @@ export namespace Models { /** * 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; + replicating?: boolean | null; /** * 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; + lagSeconds?: number | null; }; /** @@ -9622,47 +9790,47 @@ export namespace Models { /** * Bandwidth additional resources */ - bandwidth: AdditionalResource; + bandwidth?: AdditionalResource | null; /** * Executions additional resources */ - executions: AdditionalResource; + executions?: AdditionalResource | null; /** * Member additional resources */ - member?: AdditionalResource; + member?: AdditionalResource | null; /** * Realtime additional resources */ - realtime: AdditionalResource; + realtime?: AdditionalResource | null; /** * Realtime messages additional resources */ - realtimeMessages: AdditionalResource; + realtimeMessages?: AdditionalResource | null; /** * Realtime bandwidth additional resources */ - realtimeBandwidth?: AdditionalResource; + realtimeBandwidth?: AdditionalResource | null; /** * Storage additional resources */ - storage: AdditionalResource; + storage?: AdditionalResource | null; /** * User additional resources */ - users: AdditionalResource; + users?: AdditionalResource | null; /** * GBHour additional resources */ - GBHours: AdditionalResource; + GBHours?: AdditionalResource | null; /** * Image transformation additional resources */ - imageTransformations: AdditionalResource; + imageTransformations?: AdditionalResource | null; /** * Credits additional resources */ - credits?: AdditionalResource; + credits?: AdditionalResource | null; }; /** @@ -9814,7 +9982,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9856,7 +10024,7 @@ export namespace Models { /** * Time the secret was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9928,7 +10096,7 @@ export namespace Models { /** * Time an access token was last issued for the installation in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -9970,7 +10138,7 @@ export namespace Models { /** * Time the app key was last used for authentication in ISO 8601 format. Null if never used. */ - lastAccessedAt?: string; + lastAccessedAt?: string | null; }; /** @@ -10132,11 +10300,11 @@ export namespace Models { /** * Granted RFC 9396 authorization details as a JSON string. */ - authorization_details?: string; + authorization_details?: string | null; /** * OpenID Connect ID token. Returned when the `openid` scope is granted. */ - id_token?: string; + id_token?: string | null; }; /** @@ -10150,47 +10318,47 @@ export namespace Models { /** * Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. */ - token_use?: string; + token_use?: string | null; /** * OAuth2 token type. */ - token_type?: string; + token_type?: string | null; /** * Space-separated scopes granted to the token. */ - scope?: string; + scope?: string | null; /** * OAuth2 client ID the token was issued to. */ - client_id?: string; + client_id?: string | null; /** * ID of the user who authorized the token. */ - sub?: string; + sub?: string | null; /** * Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). */ - aud?: string[]; + aud?: string[] | null; /** * Issuer URL of the token. */ - iss?: string; + iss?: string | null; /** * Expiration time as a Unix timestamp in seconds. */ - exp?: number; + exp?: number | null; /** * Issued-at time as a Unix timestamp in seconds. */ - iat?: number; + iat?: number | null; /** * Unique identifier of the token. */ - jti?: string; + jti?: string | null; /** * Granted RFC 9396 authorization details, restricted to what the user can currently access. */ - authorization_details?: Record<string, any>[]; + authorization_details?: Record<string, any>[] | null; }; /** @@ -10289,6 +10457,376 @@ export namespace Models { expire: string; }; + /** + * WafRuleBypass + */ + export type WafRuleBypass = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleDeny + */ + export type WafRuleDeny = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + }; + + /** + * WafRuleChallenge + */ + export type WafRuleChallenge = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Challenge type enforced when the rule matches. + */ + challengeType: string; + /** + * Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + */ + difficulty: number; + /** + * Seconds a visitor stays cleared after passing the challenge before being challenged again. + */ + ttl: number; + }; + + /** + * WafRuleRateLimit + */ + export type WafRuleRateLimit = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Maximum number of matching requests allowed for the given interval. + */ + limit: number; + /** + * Interval in seconds for the rate limit window. + */ + interval: number; + /** + * Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + */ + key: string; + /** + * Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + */ + strategy: string; + /** + * Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + */ + maxBucketSize: number; + }; + + /** + * WafRuleRedirect + */ + export type WafRuleRedirect = { + /** + * Rule ID. + */ + $id: string; + /** + * WAF rule creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * WAF rule last update time in ISO 8601 format. + */ + $updatedAt: string; + /** + * Human friendly rule name. + */ + name: string; + /** + * Optional description for the rule. + */ + description: string; + /** + * Team ID. + */ + teamId: string; + /** + * Project ID. + */ + projectId: string; + /** + * Resource type the rule is scoped to. + */ + resourceType: string; + /** + * Resource identifier. Empty for API-wide rules. + */ + resourceId: string; + /** + * Action performed when the rule matches. + */ + action: WafRuleAction; + /** + * Evaluation priority. Lower values execute earlier. + */ + priority: number; + /** + * Whether the rule is active. + */ + enabled: boolean; + /** + * List of conditions evaluated for this rule. + */ + conditions: Record<string, any>[]; + /** + * Action specific configuration. + */ + config: object; + /** + * Target location for the redirect. + */ + location: string; + /** + * HTTP status code used for the redirect. + */ + statusCode: number; + }; + + /** + * WAF rule list + */ + export type WafRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ( + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + )[]; + }; + /** * OAuth2 Project */ diff --git a/src/query.ts b/src/query.ts index 7a7da88..ca0b350 100644 --- a/src/query.ts +++ b/src/query.ts @@ -468,6 +468,20 @@ export class Query { queries.map((query) => JSONbig.parse(query)), ).toString(); + /** + * Constrain populated related documents on a relationship attribute. + * + * @param {string} attribute The relationship attribute to query. + * @param {string[]} queries Filter, order, select, and pagination queries applied to related documents. + * @returns {string} + */ + static relationship = (attribute: string, queries: string[]): string => + new Query( + 'relationship', + attribute, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + /** * Filter resources where attribute is at a specific distance from the given coordinates. * @@ -659,4 +673,799 @@ export class Query { */ static notTouches = (attribute: string, values: any[]): string => new Query('notTouches', attribute, [values]).toString(); + + /** + * Count documents, optionally aliased. + */ + static count = (attribute: string = '*', alias: string = ''): string => + new Query( + 'count', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Count distinct values of attribute, optionally aliased. + */ + static countDistinct = (attribute: string, alias: string = ''): string => + new Query( + 'countDistinct', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sum values of `attribute`, optionally aliased. */ + static sum = (attribute: string, alias: string = ''): string => + new Query( + 'sum', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Average values of `attribute`, optionally aliased. */ + static avg = (attribute: string, alias: string = ''): string => + new Query( + 'avg', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Minimum value of `attribute`, optionally aliased. */ + static min = (attribute: string, alias: string = ''): string => + new Query( + 'min', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Maximum value of `attribute`, optionally aliased. */ + static max = (attribute: string, alias: string = ''): string => + new Query( + 'max', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Standard deviation of `attribute`, optionally aliased. */ + static stddev = (attribute: string, alias: string = ''): string => + new Query( + 'stddev', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population standard deviation of `attribute`, optionally aliased. */ + static stddevPop = (attribute: string, alias: string = ''): string => + new Query( + 'stddevPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample standard deviation of `attribute`, optionally aliased. */ + static stddevSamp = (attribute: string, alias: string = ''): string => + new Query( + 'stddevSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Variance of `attribute`, optionally aliased. */ + static variance = (attribute: string, alias: string = ''): string => + new Query( + 'variance', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Population variance of `attribute`, optionally aliased. */ + static varPop = (attribute: string, alias: string = ''): string => + new Query( + 'varPop', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Sample variance of `attribute`, optionally aliased. */ + static varSamp = (attribute: string, alias: string = ''): string => + new Query( + 'varSamp', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise AND of `attribute`, optionally aliased. */ + static bitAnd = (attribute: string, alias: string = ''): string => + new Query( + 'bitAnd', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise OR of `attribute`, optionally aliased. */ + static bitOr = (attribute: string, alias: string = ''): string => + new Query( + 'bitOr', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** Bitwise XOR of `attribute`, optionally aliased. */ + static bitXor = (attribute: string, alias: string = ''): string => + new Query( + 'bitXor', + attribute, + alias !== '' ? alias : undefined, + ).toString(); + + /** + * Group results by attributes. + */ + static groupBy = (attributes: string[]): string => + new Query('groupBy', undefined, attributes).toString(); + + /** + * Filter grouped results. `queries` are nested like `and`/`or`. + */ + static having = (queries: string[]): string => + new Query( + 'having', + undefined, + queries.map((query) => JSONbig.parse(query)), + ).toString(); + + /** Select distinct rows. */ + static distinct = (): string => new Query('distinct').toString(); + + /** + * Column-to-column join ON condition. + */ + static on = (left: string, right: string, operator: string = '='): string => + new Query('on', undefined, [left, operator, right]).toString(); + + /** + * Inner join. `table` is the joined collection/table ID. + */ + static join = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'join', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Left join. `table` is the joined collection/table ID. */ + static leftJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'leftJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Right join. `table` is the joined collection/table ID. */ + static rightJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'rightJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Full outer join. `table` is the joined collection/table ID. */ + static fullOuterJoin = ( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string => + Query.createJoin( + 'fullOuterJoin', + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ); + + /** Cross join. `table` is the joined collection/table ID. */ + static crossJoin = (table: string, alias: string = ''): string => + new Query( + 'crossJoin', + table, + alias !== '' ? alias : undefined, + ).toString(); + + /** Filter resources where `attribute` covers the given geometry. */ + static covers = (attribute: string, values: any[]): string => + new Query('covers', attribute, [values]).toString(); + + /** Filter resources where `attribute` does not cover the given geometry. */ + static notCovers = (attribute: string, values: any[]): string => + new Query('notCovers', attribute, [values]).toString(); + + /** Filter resources where `attribute` is spatially equal to the given geometry. */ + static spatialEquals = (attribute: string, values: any[]): string => + new Query('spatialEquals', attribute, [values]).toString(); + + /** Filter resources where `attribute` is not spatially equal to the given geometry. */ + static notSpatialEquals = (attribute: string, values: any[]): string => + new Query('notSpatialEquals', attribute, [values]).toString(); + + /** + * Return limit and offset queries for 1-based page pagination. + */ + static page = (page: number, perPage: number = 25): string[] => { + if (page < 1) { + throw new Error('Page must be >= 1, got ' + page); + } + if (perPage < 1) { + throw new Error('Per page must be >= 1, got ' + perPage); + } + return [Query.limit(perPage), Query.offset((page - 1) * perPage)]; + }; + + /** Start a fluent query builder. */ + static builder = (): Query.Builder => new Query.Builder(); + + private static createJoin( + method: string, + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): string { + if (Array.isArray(leftOrAliasOrOn)) { + return Query.nestedJoin(method, table, '', leftOrAliasOrOn); + } + if (Array.isArray(rightOrOn)) { + return Query.nestedJoin(method, table, leftOrAliasOrOn, rightOrOn); + } + return new Query( + method, + table, + alias !== '' + ? [leftOrAliasOrOn, operator, rightOrOn, alias] + : [leftOrAliasOrOn, operator, rightOrOn], + ).toString(); + } + + private static nestedJoin( + method: string, + table: string, + alias: string, + on: string[], + ): string { + const values: any[] = []; + if (alias !== '') { + values.push(alias); + } + for (const query of on) { + values.push(JSONbig.parse(query)); + } + return new Query(method, table, values).toString(); + } +} + +export type QueryInput = string | Query | Query.Builder | QueryInput[]; + +/** + * Fluent collector of Query fragments. Call {@link Query.Builder.build} to + * produce the `string[]` expected by list/createQuery methods. + */ +export namespace Query { + export class Builder { + private readonly queries: string[] = []; + + build(): string[] { + return [...this.queries]; + } + + equal(attribute: string, value: QueryTypes): this { + return this.push(Query.equal(attribute, value)); + } + + notEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.notEqual(attribute, value)); + } + + lessThan(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThan(attribute, value)); + } + + lessThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.lessThanEqual(attribute, value)); + } + + greaterThan(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThan(attribute, value)); + } + + greaterThanEqual(attribute: string, value: QueryTypes): this { + return this.push(Query.greaterThanEqual(attribute, value)); + } + + search(attribute: string, value: string): this { + return this.push(Query.search(attribute, value)); + } + + isNull(attribute: string): this { + return this.push(Query.isNull(attribute)); + } + + isNotNull(attribute: string): this { + return this.push(Query.isNotNull(attribute)); + } + + between( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.between(attribute, start, end)); + } + + startsWith(attribute: string, value: string): this { + return this.push(Query.startsWith(attribute, value)); + } + + endsWith(attribute: string, value: string): this { + return this.push(Query.endsWith(attribute, value)); + } + + select(attributes: string[]): this { + return this.push(Query.select(attributes)); + } + + cursorAfter(documentId: string): this { + return this.push(Query.cursorAfter(documentId)); + } + + cursorBefore(documentId: string): this { + return this.push(Query.cursorBefore(documentId)); + } + + orderAsc(attribute: string): this { + return this.push(Query.orderAsc(attribute)); + } + + orderDesc(attribute: string): this { + return this.push(Query.orderDesc(attribute)); + } + + orderRandom(): this { + return this.push(Query.orderRandom()); + } + + limit(limit: number): this { + return this.push(Query.limit(limit)); + } + + offset(offset: number): this { + return this.push(Query.offset(offset)); + } + + contains(attribute: string, value: string | any[]): this { + return this.push(Query.contains(attribute, value)); + } + + containsAny(attribute: string, value: any[]): this { + return this.push(Query.containsAny(attribute, value)); + } + + containsAll(attribute: string, value: any[]): this { + return this.push(Query.containsAll(attribute, value)); + } + + notContains(attribute: string, value: string | any[]): this { + return this.push(Query.notContains(attribute, value)); + } + + notSearch(attribute: string, value: string): this { + return this.push(Query.notSearch(attribute, value)); + } + + notBetween( + attribute: string, + start: string | number | bigint, + end: string | number | bigint, + ): this { + return this.push(Query.notBetween(attribute, start, end)); + } + + notStartsWith(attribute: string, value: string): this { + return this.push(Query.notStartsWith(attribute, value)); + } + + notEndsWith(attribute: string, value: string): this { + return this.push(Query.notEndsWith(attribute, value)); + } + + regex(attribute: string, pattern: string): this { + return this.push(Query.regex(attribute, pattern)); + } + + exists(attributes: string[]): this { + return this.push(Query.exists(attributes)); + } + + notExists(attributes: string[]): this { + return this.push(Query.notExists(attributes)); + } + + createdBefore(value: string): this { + return this.push(Query.createdBefore(value)); + } + + createdAfter(value: string): this { + return this.push(Query.createdAfter(value)); + } + + createdBetween(start: string, end: string): this { + return this.push(Query.createdBetween(start, end)); + } + + updatedBefore(value: string): this { + return this.push(Query.updatedBefore(value)); + } + + updatedAfter(value: string): this { + return this.push(Query.updatedAfter(value)); + } + + updatedBetween(start: string, end: string): this { + return this.push(Query.updatedBetween(start, end)); + } + + or(queries: string[]): this { + return this.push(Query.or(queries)); + } + + and(queries: string[]): this { + return this.push(Query.and(queries)); + } + + elemMatch(attribute: string, queries: string[]): this { + return this.push(Query.elemMatch(attribute, queries)); + } + + relationship(attribute: string, queries: string[]): this { + return this.push(Query.relationship(attribute, queries)); + } + + distanceEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceEqual(attribute, values, distance, meters), + ); + } + + distanceNotEqual( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceNotEqual(attribute, values, distance, meters), + ); + } + + distanceGreaterThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceGreaterThan(attribute, values, distance, meters), + ); + } + + distanceLessThan( + attribute: string, + values: any[], + distance: number, + meters: boolean = true, + ): this { + return this.push( + Query.distanceLessThan(attribute, values, distance, meters), + ); + } + + intersects(attribute: string, values: any[]): this { + return this.push(Query.intersects(attribute, values)); + } + + notIntersects(attribute: string, values: any[]): this { + return this.push(Query.notIntersects(attribute, values)); + } + + crosses(attribute: string, values: any[]): this { + return this.push(Query.crosses(attribute, values)); + } + + notCrosses(attribute: string, values: any[]): this { + return this.push(Query.notCrosses(attribute, values)); + } + + overlaps(attribute: string, values: any[]): this { + return this.push(Query.overlaps(attribute, values)); + } + + notOverlaps(attribute: string, values: any[]): this { + return this.push(Query.notOverlaps(attribute, values)); + } + + touches(attribute: string, values: any[]): this { + return this.push(Query.touches(attribute, values)); + } + + notTouches(attribute: string, values: any[]): this { + return this.push(Query.notTouches(attribute, values)); + } + + count(attribute: string = '*', alias: string = ''): this { + return this.push(Query.count(attribute, alias)); + } + + countDistinct(attribute: string, alias: string = ''): this { + return this.push(Query.countDistinct(attribute, alias)); + } + + sum(attribute: string, alias: string = ''): this { + return this.push(Query.sum(attribute, alias)); + } + + avg(attribute: string, alias: string = ''): this { + return this.push(Query.avg(attribute, alias)); + } + + min(attribute: string, alias: string = ''): this { + return this.push(Query.min(attribute, alias)); + } + + max(attribute: string, alias: string = ''): this { + return this.push(Query.max(attribute, alias)); + } + + stddev(attribute: string, alias: string = ''): this { + return this.push(Query.stddev(attribute, alias)); + } + + stddevPop(attribute: string, alias: string = ''): this { + return this.push(Query.stddevPop(attribute, alias)); + } + + stddevSamp(attribute: string, alias: string = ''): this { + return this.push(Query.stddevSamp(attribute, alias)); + } + + variance(attribute: string, alias: string = ''): this { + return this.push(Query.variance(attribute, alias)); + } + + varPop(attribute: string, alias: string = ''): this { + return this.push(Query.varPop(attribute, alias)); + } + + varSamp(attribute: string, alias: string = ''): this { + return this.push(Query.varSamp(attribute, alias)); + } + + bitAnd(attribute: string, alias: string = ''): this { + return this.push(Query.bitAnd(attribute, alias)); + } + + bitOr(attribute: string, alias: string = ''): this { + return this.push(Query.bitOr(attribute, alias)); + } + + bitXor(attribute: string, alias: string = ''): this { + return this.push(Query.bitXor(attribute, alias)); + } + + groupBy(attributes: string[]): this { + return this.push(Query.groupBy(attributes)); + } + + having(queries: string[]): this { + return this.push(Query.having(queries)); + } + + distinct(): this { + return this.push(Query.distinct()); + } + + join( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.join(table, leftOrAliasOrOn, rightOrOn, operator, alias), + ); + } + + leftJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.leftJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + rightJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.rightJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + fullOuterJoin( + table: string, + leftOrAliasOrOn: string | string[], + rightOrOn: string | string[] = '', + operator: string = '=', + alias: string = '', + ): this { + return this.push( + Query.fullOuterJoin( + table, + leftOrAliasOrOn, + rightOrOn, + operator, + alias, + ), + ); + } + + crossJoin(table: string, alias: string = ''): this { + return this.push(Query.crossJoin(table, alias)); + } + + vectorDot(attribute: string, vector: number[]): this { + return this.push(Query.vectorDot(attribute, vector)); + } + + vectorCosine(attribute: string, vector: number[]): this { + return this.push(Query.vectorCosine(attribute, vector)); + } + + vectorEuclidean(attribute: string, vector: number[]): this { + return this.push(Query.vectorEuclidean(attribute, vector)); + } + + covers(attribute: string, values: any[]): this { + return this.push(Query.covers(attribute, values)); + } + + notCovers(attribute: string, values: any[]): this { + return this.push(Query.notCovers(attribute, values)); + } + + spatialEquals(attribute: string, values: any[]): this { + return this.push(Query.spatialEquals(attribute, values)); + } + + notSpatialEquals(attribute: string, values: any[]): this { + return this.push(Query.notSpatialEquals(attribute, values)); + } + + page(page: number, perPage: number = 25): this { + return this.push(Query.page(page, perPage)); + } + + private push(query: string | string[]): this { + if (Array.isArray(query)) { + this.queries.push(...query); + } else { + this.queries.push(query); + } + return this; + } + } +} + +export function normalizeQueries(queries?: QueryInput | null): string[] { + if (queries == null) { + return []; + } + if (queries instanceof Query.Builder) { + return queries.build(); + } + if (!Array.isArray(queries)) { + if (queries instanceof Query) { + return [queries.toString()]; + } + if (typeof queries === 'string') { + return [queries]; + } + return []; + } + + const out: string[] = []; + for (const item of queries) { + out.push(...normalizeQueries(item)); + } + return out; } + +function isQueryValue(value: unknown): value is Query | Query.Builder { + return value instanceof Query.Builder || value instanceof Query; +} + +export function flattenParam(value: unknown): unknown { + if (isQueryValue(value)) { + return normalizeQueries(value); + } + if (!Array.isArray(value)) { + return value; + } + + const out: unknown[] = []; + for (const item of value) { + if (isQueryValue(item)) { + out.push(...normalizeQueries(item)); + } else { + out.push(flattenParam(item)); + } + } + return out; +} + +export const QueryBuilder = Query.Builder; +export type QueryBuilder = Query.Builder; diff --git a/src/services/account.ts b/src/services/account.ts index 1714a6f..8c05720 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; @@ -30,7 +35,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -138,7 +186,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -206,7 +297,39 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentList', + models: { + oauth2ConsentList: { + defaults: { + total: 0, + consents: [], + }, + properties: { + consents: { + items: 'oauth2Consent', + }, + }, + }, + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -261,7 +384,28 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Consent', + models: { + oauth2Consent: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -398,7 +542,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentTokenList', + models: { + oauth2ConsentTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'oauth2ConsentToken', + }, + }, + }, + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -471,7 +648,29 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ConsentToken', + models: { + oauth2ConsentToken: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + consentId: '', + userId: '', + appId: '', + cimdUrl: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -625,7 +824,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +935,40 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -809,7 +1084,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1185,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,7 +1255,20 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaType', + models: { + mfaType: { + defaults: { + secret: '', + uri: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1004,7 +1348,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1083,7 +1470,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1254,7 +1684,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1313,7 +1758,22 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallenge', + models: { + mfaChallenge: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1390,7 +1850,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1466,7 +1966,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1486,7 +2026,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1505,7 +2061,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1525,7 +2097,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1544,7 +2128,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1565,7 +2161,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2193,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1606,7 +2226,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1626,7 +2258,19 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1686,7 +2330,538 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by the currently logged in user. + * + * @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.PasskeyList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/account/passkeys'; + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} params.passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskey(params?: { + passkeyId?: string; + name?: string; + }): Promise<Models.PasskeyChallenge>; + /** + * Start registering a passkey for the currently logged in user. The session must have signed in or completed an MFA challenge within the last 10 minutes. Pass the returned `publicKey` options to `navigator.credentials.create()`, then complete the registration with [Update passkey verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). The passkey stays pending until verified, and the challenge expires after 5 minutes. + * + * @param {string} passkeyId - Passkey 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 - Passkey name, shown when listing passkeys. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPasskey( + passkeyId?: string, + name?: string, + ): Promise<Models.PasskeyChallenge>; + createPasskey( + paramsOrFirst?: { passkeyId?: string; name?: string } | string, + ...rest: [string?] + ): Promise<Models.PasskeyChallenge> { + let params: { passkeyId?: string; name?: string }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + passkeyId?: string; + name?: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + const apiPath = '/account/passkeys'; + const apiPayload: Payload = {}; + if (typeof passkeyId !== 'undefined') { + apiPayload['passkeyId'] = passkeyId; + } + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { passkeyId: string }): Promise<Models.Passkey>; + /** + * Get a verified passkey of the currently logged in user by its unique ID. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { passkeyId: string } | string, + ): Promise<Models.Passkey> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of the currently logged in user. + * + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey(passkeyId: string, name: string): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: { passkeyId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + name: string; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from the currently logged in user. The passkey can no longer be used to sign in, although it may remain stored on the user's device. The session must have signed in or completed an MFA challenge within the last 10 minutes. + * + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(passkeyId: string): Promise<{}>; + deletePasskey(paramsOrFirst: { passkeyId: string } | string): Promise<{}> { + let params: { passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { passkeyId: string }; + } else { + params = { + passkeyId: paramsOrFirst as string, + }; + } + + const passkeyId = params.passkeyId; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + 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); + } + + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} params.passkeyId - Passkey ID. + * @param {object} params.credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskeyVerification(params: { + passkeyId: string; + credential: object; + }): Promise<Models.Passkey>; + /** + * Complete a passkey registration started with [Create passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the JSON form of the credential returned by `navigator.credentials.create()`, for example `credential.toJSON()`. Each registration can be verified once; a failed attempt requires starting it again. + * + * @param {string} passkeyId - Passkey ID. + * @param {object} credential - Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyVerification( + passkeyId: string, + credential: object, + ): Promise<Models.Passkey>; + updatePasskeyVerification( + paramsOrFirst: { passkeyId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.Passkey> { + let params: { passkeyId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + passkeyId: string; + credential: object; + }; + } else { + params = { + passkeyId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const passkeyId = params.passkeyId; + const credential = params.credential; + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/passkeys/{passkeyId}/verification'.replace( + '{passkeyId}', + encodeURIComponent(String(passkeyId)), + ); + const apiPayload: Payload = {}; + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2940,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1844,7 +3062,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1928,7 +3189,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1996,7 +3300,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2090,7 +3411,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2164,7 +3502,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2256,7 +3611,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2307,7 +3679,58 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2379,7 +3802,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2389,14 +3852,14 @@ export class Account { * * @param {string} params.email - User email. * @param {string} params.password - User password. Must be at least 8 chars. - * @param {number} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} params.duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} */ createEmailPasswordSession(params: { email: string; password: string; - duration?: number; + duration?: number | null; }): Promise<Models.Session>; /** * 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. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. @@ -2405,7 +3868,7 @@ export class Account { * * @param {string} email - User email. * @param {string} password - User password. Must be at least 8 chars. - * @param {number} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + * @param {number | null} duration - Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. * @throws {AppwriteException} * @returns {Promise<Models.Session>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2413,14 +3876,19 @@ export class Account { createEmailPasswordSession( email: string, password: string, - duration?: number, + duration?: number | null, ): Promise<Models.Session>; createEmailPasswordSession( paramsOrFirst: - { email: string; password: string; duration?: number } | string, - ...rest: [string?, number?] + | { email: string; password: string; duration?: number | null } + | string, + ...rest: [string?, (number | null)?] ): Promise<Models.Session> { - let params: { email: string; password: string; duration?: number }; + let params: { + email: string; + password: string; + duration?: number | null; + }; if ( paramsOrFirst && @@ -2430,13 +3898,13 @@ export class Account { params = (paramsOrFirst || {}) as { email: string; password: string; - duration?: number; + duration?: number | null; }; } else { params = { email: paramsOrFirst as string, password: rest[0] as string, - duration: rest[1] as number, + duration: rest[1] as number | null, }; } @@ -2470,7 +3938,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2632,7 +4140,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2707,7 +4255,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2779,7 +4367,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2850,7 +4478,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2905,7 +4573,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2961,7 +4669,47 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3037,7 +4785,50 @@ export class Account { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3128,7 +4919,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3235,7 +5043,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3251,6 +5076,7 @@ export class Account { * @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. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} */ @@ -3259,6 +5085,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise<string>; /** * 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. @@ -3273,6 +5100,7 @@ export class Account { * @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. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise<string>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3282,6 +5110,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise<string>; createOAuth2Token( paramsOrFirst: @@ -3290,15 +5119,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise<string> { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -3308,13 +5139,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -3322,6 +5155,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -3329,6 +5163,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3348,6 +5183,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3358,6 +5196,137 @@ export class Account { return this.client.redirect('get', uri, apiHeaders, apiPayload); } + /** + * Start signing in with a passkey. No email or user ID is needed: pass the returned `publicKey` options to `navigator.credentials.get()` and the user picks one of their passkeys. Then call [Update passkey token](/docs/references/cloud/client-web/account#updatePasskeyToken) with the credential to receive a token, and exchange it with [Create session](/docs/references/cloud/client-web/account#createSession). The challenge expires after 5 minutes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyChallenge>} + */ + createPasskeyToken(): Promise<Models.PasskeyChallenge> { + const apiPath = '/account/tokens/passkey'; + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyChallenge', + models: { + passkeyChallenge: { + defaults: { + $id: '', + $createdAt: '', + passkeyId: '', + expire: '', + publicKey: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} params.challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} params.credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + */ + updatePasskeyToken(params: { + challengeId: string; + credential: object; + }): Promise<Models.TokenSecret>; + /** + * Complete a passkey sign-in started with [Create passkey token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass the challenge ID and the JSON form of the credential returned by `navigator.credentials.get()`, for example `credential.toJSON()`. The returned token includes its secret and expires after 1 minute: exchange it for a session with [Create session](/docs/references/cloud/client-web/account#createSession). Passkeys require user verification, so the session also satisfies MFA. Each challenge can only be used once. + * + * @param {string} challengeId - Challenge ID returned by createPasskeyToken. + * @param {object} credential - Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + * @throws {AppwriteException} + * @returns {Promise<Models.TokenSecret>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyToken( + challengeId: string, + credential: object, + ): Promise<Models.TokenSecret>; + updatePasskeyToken( + paramsOrFirst: { challengeId: string; credential: object } | string, + ...rest: [object?] + ): Promise<Models.TokenSecret> { + let params: { challengeId: string; credential: object }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + challengeId: string; + credential: object; + }; + } else { + params = { + challengeId: paramsOrFirst as string, + credential: rest[0] as object, + }; + } + + const challengeId = params.challengeId; + const credential = params.credential; + if (typeof challengeId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "challengeId"', + ); + } + if (typeof credential === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "credential"', + ); + } + const apiPath = '/account/tokens/passkey'; + const apiPayload: Payload = {}; + if (typeof challengeId !== 'undefined') { + apiPayload['challengeId'] = challengeId; + } + if (typeof credential !== 'undefined') { + apiPayload['credential'] = credential; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tokenSecret', + models: { + tokenSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + /** * 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. * @@ -3427,7 +5396,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3487,7 +5473,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +5551,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3622,7 +5642,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3694,7 +5731,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3754,7 +5808,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3830,7 +5901,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3850,7 +5938,24 @@ export class Account { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3924,6 +6029,23 @@ export class Account { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/activities.ts b/src/services/activities.ts index 74bae79..d082ca4 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Activities { @@ -58,7 +63,58 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEventList', + models: { + activityEventList: { + defaults: { + total: 0, + events: [], + }, + properties: { + events: { + items: 'activityEvent', + }, + }, + }, + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -115,6 +171,46 @@ export class Activities { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'activityEvent', + models: { + activityEvent: { + defaults: { + $id: '', + actorType: '', + actorId: '', + actorEmail: '', + actorName: '', + resourceParent: '', + resourceType: '', + resourceId: '', + resource: '', + event: '', + userAgent: '', + ip: '', + mode: '', + country: '', + continentCode: '', + city: '', + subdivisions: '', + isp: '', + autonomousSystemNumber: '', + autonomousSystemOrganization: '', + connectionType: '', + connectionUsageType: '', + connectionOrganization: '', + time: '', + projectId: '', + teamId: '', + hostname: '', + sdk: '', + sdkVersion: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/advisor.ts b/src/services/advisor.ts index 0ffcdfb..b19ab4f 100644 --- a/src/services/advisor.ts +++ b/src/services/advisor.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Advisor { @@ -75,7 +80,76 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'reportList', + models: { + reportList: { + defaults: { + total: 0, + reports: [], + }, + properties: { + reports: { + items: 'report', + }, + }, + }, + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -132,7 +206,65 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'report', + models: { + report: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + type: '', + title: '', + summary: '', + targetType: '', + target: '', + categories: [], + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -273,7 +405,56 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insightList', + models: { + insightList: { + defaults: { + total: 0, + insights: [], + }, + properties: { + insights: { + items: 'insight', + }, + }, + }, + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,6 +526,44 @@ export class Advisor { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'insight', + models: { + insight: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + reportId: '', + type: '', + severity: 'info', + status: 'active', + resourceType: '', + resourceId: '', + parentResourceType: '', + parentResourceId: '', + title: '', + summary: '', + ctas: [], + }, + properties: { + ctas: { + items: 'insightCTA', + }, + }, + }, + insightCTA: { + defaults: { + label: '', + service: '', + method: '', + params: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/apps.ts b/src/services/apps.ts index 54b4b2c..ff362ed 100644 --- a/src/services/apps.ts +++ b/src/services/apps.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Apps { @@ -70,7 +75,72 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appsList', + models: { + appsList: { + defaults: { + total: 0, + apps: [], + }, + properties: { + apps: { + items: 'app', + }, + }, + }, + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -380,7 +450,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -399,7 +523,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +569,34 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appScopeList', + models: { + appScopeList: { + defaults: { + total: 0, + scopes: [], + }, + properties: { + scopes: { + items: 'appScope', + }, + }, + }, + appScope: { + defaults: { + value: '', + description: '', + type: '', + category: '', + deprecated: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -469,7 +647,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -787,7 +1019,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -920,7 +1206,38 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -994,7 +1311,27 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1141,7 +1478,23 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1222,7 +1575,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKeyList', + models: { + appKeyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'appKey', + }, + }, + }, + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1276,7 +1659,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1336,7 +1738,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appKey', + models: { + appKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1468,7 +1889,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1549,7 +2024,37 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretList', + models: { + appSecretList: { + defaults: { + total: 0, + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1603,7 +2108,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecretPlaintext', + models: { + appSecretPlaintext: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1671,7 +2195,26 @@ export class Apps { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appSecret', + models: { + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1802,7 +2345,61 @@ export class Apps { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'app', + models: { + app: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + clientUri: '', + logoUri: '', + privacyPolicyUrl: '', + termsUrl: '', + contacts: [], + tagline: '', + tags: [], + labels: [], + images: [], + supportUrl: '', + dataDeletionUrl: '', + redirectUris: [], + postLogoutRedirectUris: [], + enabled: true, + type: 'confidential', + deviceFlow: false, + teamId: '', + userId: '', + installationScopes: [], + installationRedirectUrl: '', + secrets: [], + }, + properties: { + secrets: { + items: 'appSecret', + }, + }, + }, + appSecret: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + secret: '', + hint: '', + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/backups.ts b/src/services/backups.ts index 633bb09..d8dfb94 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { BackupServices } from '../enums/backup-services'; @@ -59,41 +64,71 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchiveList', + models: { + backupArchiveList: { + defaults: { + total: 0, + archives: [], + }, + properties: { + archives: { + items: 'backupArchive', + }, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} params.services - Array of services to backup - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} */ createArchive(params: { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }): Promise<Models.BackupArchive>; /** * Create a new archive asynchronously for a project. * * @param {BackupServices[]} services - Array of services to backup - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @throws {AppwriteException} * @returns {Promise<Models.BackupArchive>} * @deprecated Use the object parameter style method for a better developer experience. */ createArchive( services: BackupServices[], - resourceId?: string, + resourceId?: string | null, ): Promise<Models.BackupArchive>; createArchive( paramsOrFirst: - | { services: BackupServices[]; resourceId?: string } + | { services: BackupServices[]; resourceId?: string | null } | BackupServices[], - ...rest: [string?] + ...rest: [(string | null)?] ): Promise<Models.BackupArchive> { - let params: { services: BackupServices[]; resourceId?: string }; + let params: { services: BackupServices[]; resourceId?: string | null }; if ( paramsOrFirst && @@ -103,12 +138,12 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { services: BackupServices[]; - resourceId?: string; + resourceId?: string | null; }; } else { params = { services: paramsOrFirst as BackupServices[], - resourceId: rest[0] as string, + resourceId: rest[0] as string | null, }; } @@ -135,7 +170,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -190,7 +244,26 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupArchive', + models: { + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -297,7 +370,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +413,7 @@ export class Backups { * @param {number} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Schedule CRON syntax. * @param {string} params.name - Policy name. Max length: 128 chars. - * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} params.resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -319,7 +424,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }): Promise<Models.BackupPolicy>; /** @@ -330,7 +435,7 @@ export class Backups { * @param {number} retention - Days to keep backups before deletion * @param {string} schedule - Schedule CRON syntax. * @param {string} name - Policy name. Max length: 128 chars. - * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {string | null} resourceId - Resource ID. When set, only this single resource will be backed up. * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} @@ -342,7 +447,7 @@ export class Backups { retention: number, schedule: string, name?: string, - resourceId?: string, + resourceId?: string | null, enabled?: boolean, ): Promise<Models.BackupPolicy>; createPolicy( @@ -353,7 +458,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; } | string, @@ -362,7 +467,7 @@ export class Backups { number?, string?, string?, - string?, + (string | null)?, boolean?, ] ): Promise<Models.BackupPolicy> { @@ -372,7 +477,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; @@ -387,7 +492,7 @@ export class Backups { retention: number; schedule: string; name?: string; - resourceId?: string; + resourceId?: string | null; enabled?: boolean; }; } else { @@ -397,7 +502,7 @@ export class Backups { retention: rest[1] as number, schedule: rest[2] as string, name: rest[3] as string, - resourceId: rest[4] as string, + resourceId: rest[4] as string | null, enabled: rest[5] as boolean, }; } @@ -460,7 +565,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -515,64 +641,90 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update an existing policy using it's ID. * * @param {string} params.policyId - Policy ID. Choose a custom ID`. 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 {number} params.retention - Days to keep backups before deletion + * @param {string | null} params.name - Policy name. Max length: 128 chars. + * @param {number | null} params.retention - Days to keep backups before deletion * @param {string} params.schedule - Cron expression - * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updatePolicy(params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * Update an existing policy using it's ID. * * @param {string} policyId - Policy ID. Choose a custom ID`. 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 {number} retention - Days to keep backups before deletion + * @param {string | null} name - Policy name. Max length: 128 chars. + * @param {number | null} retention - Days to keep backups before deletion * @param {string} schedule - Cron expression - * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @param {boolean | null} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePolicy( policyId: string, - name?: string, - retention?: number, + name?: string | null, + retention?: number | null, schedule?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updatePolicy( paramsOrFirst: | { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, number?, string?, boolean?] + ...rest: [ + (string | null)?, + (number | null)?, + string?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -582,18 +734,18 @@ export class Backups { ) { params = (paramsOrFirst || {}) as { policyId: string; - name?: string; - retention?: number; + name?: string | null; + retention?: number | null; schedule?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { policyId: paramsOrFirst as string, - name: rest[0] as string, - retention: rest[1] as number, + name: rest[0] as string | null, + retention: rest[1] as number | null, schedule: rest[2] as string, - enabled: rest[3] as boolean, + enabled: rest[3] as boolean | null, }; } @@ -632,7 +784,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -814,7 +987,28 @@ export class Backups { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -867,7 +1061,39 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestorationList', + models: { + backupRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'backupRestoration', + }, + }, + }, + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -924,6 +1150,27 @@ export class Backups { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupRestoration', + models: { + backupRestoration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + archiveId: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + options: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/databases.ts b/src/services/databases.ts index 03929fd..0b2d328 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -89,7 +94,69 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +246,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -248,7 +366,35 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -301,7 +447,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,7 +522,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -449,7 +629,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -582,7 +779,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +852,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -723,7 +988,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,7 +1199,58 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -892,11 +1259,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. @@ -905,7 +1272,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -917,11 +1284,11 @@ export class Databases { * @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 {string[] | null} 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). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Collection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -930,7 +1297,7 @@ export class Databases { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -942,7 +1309,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -952,7 +1319,7 @@ export class Databases { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -963,7 +1330,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -979,7 +1346,7 @@ export class Databases { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -990,7 +1357,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1053,7 +1420,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1130,7 +1537,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1139,7 +1586,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1151,7 +1598,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1162,7 +1609,7 @@ export class Databases { * @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 {string[] | null} 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. @@ -1174,7 +1621,7 @@ export class Databases { databaseId: string, collectionId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1185,19 +1632,26 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Collection> { let params: { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1212,7 +1666,7 @@ export class Databases { databaseId: string; collectionId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1222,7 +1676,7 @@ export class Databases { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -1276,7 +1730,47 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1461,7 +1955,20 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeList', + models: { + attributeList: { + defaults: { + total: 0, + attributes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1472,9 +1979,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1485,9 +1992,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeBigint>; /** @@ -1498,9 +2005,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} @@ -1511,9 +2018,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeBigint>; createBigIntAttribute( @@ -1523,9 +2030,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -1533,9 +2040,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeBigint> { @@ -1544,9 +2051,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -1560,9 +2067,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -1571,9 +2078,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -1638,7 +2145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1649,10 +2173,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. @@ -1662,10 +2186,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeBigint>; /** * Update a bigint attribute. Changing the `default` value will not update already existing documents. @@ -1675,10 +2199,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1688,10 +2212,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeBigint>; updateBigIntAttribute( paramsOrFirst: @@ -1700,20 +2224,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeBigint> { let params: { @@ -1721,10 +2245,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -1737,10 +2261,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -1748,10 +2272,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -1818,7 +2342,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBigint', + models: { + attributeBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1829,7 +2370,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1840,7 +2381,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.AttributeBoolean>; /** @@ -1851,7 +2392,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} @@ -1862,7 +2403,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.AttributeBoolean>; createBooleanAttribute( @@ -1872,18 +2413,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -1897,7 +2438,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -1906,7 +2447,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -1963,7 +2504,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1973,8 +2531,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {boolean | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. @@ -1984,8 +2542,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.AttributeBoolean>; /** * Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -1994,8 +2552,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {boolean | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2005,8 +2563,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.AttributeBoolean>; updateBooleanAttribute( paramsOrFirst: @@ -2015,19 +2573,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.AttributeBoolean> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2040,8 +2604,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2049,8 +2613,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2109,7 +2673,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeBoolean', + models: { + attributeBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2119,7 +2700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2130,7 +2711,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeDatetime>; /** @@ -2140,7 +2721,7 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} @@ -2151,7 +2732,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeDatetime>; createDatetimeAttribute( @@ -2161,18 +2742,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2186,7 +2767,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2195,7 +2776,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2252,7 +2833,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2262,8 +2860,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. @@ -2273,8 +2871,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeDatetime>; /** * Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -2283,8 +2881,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2294,8 +2892,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeDatetime>; updateDatetimeAttribute( paramsOrFirst: @@ -2304,19 +2902,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeDatetime> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2329,8 +2933,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2338,8 +2942,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2398,7 +3002,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeDatetime', + models: { + attributeDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2409,7 +3030,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2420,7 +3041,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEmail>; /** @@ -2431,7 +3052,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} @@ -2442,7 +3063,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEmail>; createEmailAttribute( @@ -2452,18 +3073,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2477,7 +3098,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2486,7 +3107,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2543,7 +3164,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2554,8 +3193,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. @@ -2565,8 +3204,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEmail>; /** * Update an email attribute. Changing the `default` value will not update already existing documents. @@ -2576,8 +3215,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2587,8 +3226,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEmail>; updateEmailAttribute( paramsOrFirst: @@ -2597,19 +3236,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEmail> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2622,8 +3267,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2631,8 +3276,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -2691,7 +3336,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEmail', + models: { + attributeEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2703,7 +3366,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2715,7 +3378,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeEnum>; /** @@ -2727,7 +3390,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} @@ -2739,7 +3402,7 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeEnum>; createEnumAttribute( @@ -2750,11 +3413,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2762,7 +3432,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2777,7 +3447,7 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2787,7 +3457,7 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -2853,7 +3523,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2865,8 +3554,8 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. @@ -2877,8 +3566,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeEnum>; /** * Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -2889,8 +3578,8 @@ export class Databases { * @param {string} key - Attribute Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2901,8 +3590,8 @@ export class Databases { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeEnum>; updateEnumAttribute( paramsOrFirst: @@ -2912,11 +3601,18 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeEnum> { let params: { databaseId: string; @@ -2924,8 +3620,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -2939,8 +3635,8 @@ export class Databases { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -2949,8 +3645,8 @@ export class Databases { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3018,7 +3714,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeEnum', + models: { + attributeEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3029,9 +3744,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3042,9 +3757,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.AttributeFloat>; /** @@ -3055,9 +3770,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} @@ -3068,9 +3783,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.AttributeFloat>; createFloatAttribute( @@ -3080,9 +3795,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3090,9 +3805,9 @@ export class Databases { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.AttributeFloat> { @@ -3101,9 +3816,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3117,9 +3832,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3128,9 +3843,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3195,7 +3910,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3206,10 +3938,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value. - * @param {number} params.max - Maximum value. - * @param {string} params.newKey - New Attribute Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value. + * @param {number | null} params.max - Maximum value. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. @@ -3219,10 +3951,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.AttributeFloat>; /** * Update a float attribute. Changing the `default` value will not update already existing documents. @@ -3232,10 +3964,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value. - * @param {number} max - Maximum value. - * @param {string} newKey - New Attribute Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value. + * @param {number | null} max - Maximum value. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3245,10 +3977,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.AttributeFloat>; updateFloatAttribute( paramsOrFirst: @@ -3257,20 +3989,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.AttributeFloat> { let params: { @@ -3278,10 +4010,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3294,10 +4026,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3305,10 +4037,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -3375,7 +4107,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeFloat', + models: { + attributeFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3386,9 +4135,9 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3399,9 +4148,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.AttributeInteger>; /** @@ -3412,9 +4161,9 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} @@ -3425,9 +4174,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.AttributeInteger>; createIntegerAttribute( @@ -3437,9 +4186,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -3447,9 +4196,9 @@ export class Databases { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.AttributeInteger> { @@ -3458,9 +4207,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -3474,9 +4223,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -3485,9 +4234,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -3552,7 +4301,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3563,10 +4329,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Attribute Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. @@ -3576,10 +4342,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.AttributeInteger>; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -3589,10 +4355,10 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Attribute Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3602,10 +4368,10 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.AttributeInteger>; updateIntegerAttribute( paramsOrFirst: @@ -3614,20 +4380,20 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.AttributeInteger> { let params: { @@ -3635,10 +4401,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -3651,10 +4417,10 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -3662,10 +4428,10 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -3732,7 +4498,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeInteger', + models: { + attributeInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3743,7 +4526,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3754,7 +4537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeIp>; /** @@ -3765,7 +4548,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} @@ -3776,7 +4559,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeIp>; createIpAttribute( @@ -3786,18 +4569,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3811,7 +4594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3820,7 +4603,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3877,7 +4660,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3888,8 +4689,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. @@ -3899,8 +4700,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeIp>; /** * Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -3910,8 +4711,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3921,8 +4722,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeIp>; updateIpAttribute( paramsOrFirst: @@ -3931,19 +4732,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeIp> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3956,8 +4763,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3965,8 +4772,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4025,7 +4832,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeIp', + models: { + attributeIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4035,7 +4860,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. @@ -4045,7 +4870,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributeLine>; /** * Create a geometric line attribute. @@ -4054,7 +4879,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4064,7 +4889,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributeLine>; createLineAttribute( paramsOrFirst: @@ -4073,17 +4898,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4096,7 +4921,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4104,7 +4929,7 @@ export class Databases { 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[][] | null, }; } @@ -4156,7 +4981,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4166,8 +5008,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. @@ -4177,8 +5019,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributeLine>; /** * Update a line attribute. Changing the `default` value will not update already existing documents. @@ -4187,8 +5029,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4198,8 +5040,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributeLine>; updateLineAttribute( paramsOrFirst: @@ -4208,19 +5050,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLine> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4233,8 +5081,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4242,8 +5090,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4297,7 +5145,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLine', + models: { + attributeLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4308,7 +5173,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4320,7 +5185,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeLongtext>; @@ -4332,7 +5197,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4344,7 +5209,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeLongtext>; @@ -4355,19 +5220,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4382,7 +5254,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4392,7 +5264,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4454,7 +5326,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4465,8 +5354,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLongtextColumn` instead. @@ -4476,8 +5365,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeLongtext>; /** * Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -4487,8 +5376,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4498,8 +5387,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeLongtext>; updateLongtextAttribute( paramsOrFirst: @@ -4508,19 +5397,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeLongtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4533,8 +5428,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4542,8 +5437,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4602,7 +5497,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeLongtext', + models: { + attributeLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4613,7 +5525,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4625,7 +5537,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeMediumtext>; @@ -4637,7 +5549,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -4649,7 +5561,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeMediumtext>; @@ -4660,19 +5572,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4687,7 +5606,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -4697,7 +5616,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -4759,7 +5678,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4770,8 +5706,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateMediumtextColumn` instead. @@ -4781,8 +5717,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeMediumtext>; /** * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -4792,8 +5728,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4803,8 +5739,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeMediumtext>; updateMediumtextAttribute( paramsOrFirst: @@ -4813,19 +5749,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeMediumtext> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4838,8 +5780,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4847,8 +5789,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4907,7 +5849,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeMediumtext', + models: { + attributeMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4917,7 +5876,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. @@ -4927,7 +5886,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.AttributePoint>; /** * Create a geometric point attribute. @@ -4936,7 +5895,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4946,7 +5905,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.AttributePoint>; createPointAttribute( paramsOrFirst: @@ -4955,17 +5914,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -4978,7 +5937,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -4986,7 +5945,7 @@ export class Databases { 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[] | null, }; } @@ -5038,7 +5997,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5048,8 +6024,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {number[] | null} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. @@ -5059,8 +6035,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.AttributePoint>; /** * Update a point attribute. Changing the `default` value will not update already existing documents. @@ -5069,8 +6045,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {number[] | null} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5080,8 +6056,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.AttributePoint>; updatePointAttribute( paramsOrFirst: @@ -5090,19 +6066,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePoint> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5115,8 +6097,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5124,8 +6106,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5179,7 +6161,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePoint', + models: { + attributePoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5189,7 +6188,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. @@ -5199,7 +6198,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.AttributePolygon>; /** * Create a geometric polygon attribute. @@ -5208,7 +6207,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5218,7 +6217,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.AttributePolygon>; createPolygonAttribute( paramsOrFirst: @@ -5227,17 +6226,17 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5250,7 +6249,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5258,7 +6257,7 @@ export class Databases { 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[][] | null, }; } @@ -5310,7 +6309,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5320,8 +6336,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {any[][]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} params.newKey - New attribute key. + * @param {any[][] | null} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. @@ -5331,8 +6347,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.AttributePolygon>; /** * Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -5341,8 +6357,8 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {any[][]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. - * @param {string} newKey - New attribute key. + * @param {any[][] | null} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string | null} newKey - New attribute key. * @throws {AppwriteException} * @returns {Promise<Models.AttributePolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5352,8 +6368,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.AttributePolygon>; updatePolygonAttribute( paramsOrFirst: @@ -5362,19 +6378,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.AttributePolygon> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -5387,8 +6409,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -5396,8 +6418,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -5451,7 +6473,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributePolygon', + models: { + attributePolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5463,8 +6502,8 @@ export class Databases { * @param {string} params.relatedCollectionId - Related Collection ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Attribute Key. - * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {string | null} params.key - Attribute Key. + * @param {string | null} params.twoWayKey - Two Way Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5476,8 +6515,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.AttributeRelationship>; /** @@ -5489,8 +6528,8 @@ export class Databases { * @param {string} relatedCollectionId - Related Collection ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Attribute Key. - * @param {string} twoWayKey - Two Way Attribute Key. + * @param {string | null} key - Attribute Key. + * @param {string | null} twoWayKey - Two Way Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} @@ -5502,8 +6541,8 @@ export class Databases { relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.AttributeRelationship>; createRelationshipAttribute( @@ -5514,8 +6553,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -5524,8 +6563,8 @@ export class Databases { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.AttributeRelationship> { @@ -5535,8 +6574,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -5551,8 +6590,8 @@ export class Databases { relatedCollectionId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -5562,8 +6601,8 @@ export class Databases { relatedCollectionId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -5628,7 +6667,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5639,7 +6700,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. @@ -5649,7 +6710,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }): Promise<Models.AttributeRelationship>; /** * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -5659,7 +6720,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Attribute Key. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5669,7 +6730,7 @@ export class Databases { collectionId: string, key: string, onDelete?: RelationMutate, - newKey?: string, + newKey?: string | null, ): Promise<Models.AttributeRelationship>; updateRelationshipAttribute( paramsOrFirst: @@ -5678,17 +6739,17 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, RelationMutate?, (string | null)?] ): Promise<Models.AttributeRelationship> { let params: { databaseId: string; collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; if ( @@ -5701,7 +6762,7 @@ export class Databases { collectionId: string; key: string; onDelete?: RelationMutate; - newKey?: string; + newKey?: string | null; }; } else { params = { @@ -5709,7 +6770,7 @@ export class Databases { 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 | null, }; } @@ -5754,7 +6815,29 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeRelationship', + models: { + attributeRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5766,7 +6849,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for text attributes, in number of characters. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5779,7 +6862,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeString>; @@ -5792,7 +6875,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for text attributes, in number of characters. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -5805,7 +6888,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeString>; @@ -5817,7 +6900,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -5827,7 +6910,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -5838,7 +6921,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5854,7 +6937,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5865,7 +6948,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -5934,7 +7017,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5945,9 +7046,9 @@ export class Databases { * @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). * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the string attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the string attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. @@ -5957,9 +7058,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeString>; /** * Update a string attribute. Changing the `default` value will not update already existing documents. @@ -5969,9 +7070,9 @@ export class Databases { * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the string attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the string attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5981,9 +7082,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeString>; updateStringAttribute( paramsOrFirst: @@ -5992,21 +7093,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeString> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6019,9 +7127,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6029,9 +7137,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6094,7 +7202,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeString', + models: { + attributeString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6105,7 +7231,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6117,7 +7243,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeText>; @@ -6129,7 +7255,7 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6141,7 +7267,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeText>; @@ -6152,19 +7278,26 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6179,7 +7312,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6189,7 +7322,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6251,7 +7384,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6262,8 +7412,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6273,8 +7423,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeText>; /** * Update a text attribute. Changing the `default` value will not update already existing documents. @@ -6284,8 +7434,8 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6295,8 +7445,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeText>; updateTextAttribute( paramsOrFirst: @@ -6305,19 +7455,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeText> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6330,8 +7486,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6339,8 +7495,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6399,7 +7555,24 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeText', + models: { + attributeText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6410,7 +7583,7 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6421,7 +7594,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.AttributeUrl>; /** @@ -6432,7 +7605,7 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} @@ -6443,7 +7616,7 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.AttributeUrl>; createUrlAttribute( @@ -6453,18 +7626,18 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -6478,7 +7651,7 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -6487,7 +7660,7 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -6544,7 +7717,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6555,8 +7746,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. @@ -6566,8 +7757,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.AttributeUrl>; /** * Update an url attribute. Changing the `default` value will not update already existing documents. @@ -6577,8 +7768,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6588,8 +7779,8 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.AttributeUrl>; updateUrlAttribute( paramsOrFirst: @@ -6598,19 +7789,25 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.AttributeUrl> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6623,8 +7820,8 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6632,8 +7829,8 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -6692,7 +7889,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeUrl', + models: { + attributeUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6704,7 +7919,7 @@ export class Databases { * @param {string} params.key - Attribute Key. * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6717,7 +7932,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.AttributeVarchar>; @@ -6730,7 +7945,7 @@ export class Databases { * @param {string} key - Attribute Key. * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. * @throws {AppwriteException} @@ -6743,7 +7958,7 @@ export class Databases { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.AttributeVarchar>; @@ -6755,7 +7970,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6765,7 +7980,7 @@ export class Databases { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6776,7 +7991,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6792,7 +8007,7 @@ export class Databases { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6803,7 +8018,7 @@ export class Databases { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6872,7 +8087,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6883,9 +8116,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} params.size - Maximum size of the varchar attribute. - * @param {string} params.newKey - New Attribute Key. + * @param {string | null} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} params.size - Maximum size of the varchar attribute. + * @param {string | null} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateVarcharColumn` instead. @@ -6895,9 +8128,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.AttributeVarchar>; /** * Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -6907,9 +8140,9 @@ export class Databases { * @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 - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. - * @param {number} size - Maximum size of the varchar attribute. - * @param {string} newKey - New Attribute Key. + * @param {string | null} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number | null} size - Maximum size of the varchar attribute. + * @param {string | null} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise<Models.AttributeVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6919,9 +8152,9 @@ export class Databases { collectionId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.AttributeVarchar>; updateVarcharAttribute( paramsOrFirst: @@ -6930,21 +8163,28 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.AttributeVarchar> { let params: { databaseId: string; collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6957,9 +8197,9 @@ export class Databases { collectionId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6967,9 +8207,9 @@ export class Databases { collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7032,7 +8272,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'attributeVarchar', + models: { + attributeVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7406,7 +8664,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7416,8 +8703,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. @@ -7431,8 +8718,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -7441,8 +8728,8 @@ export class Databases { * @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<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7454,8 +8741,8 @@ export class Databases { data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7467,8 +8754,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -7478,8 +8765,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -7490,8 +8777,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -7507,8 +8794,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -7519,8 +8806,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -7576,7 +8863,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7585,7 +8890,7 @@ export class Databases { * @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. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. @@ -7596,7 +8901,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7604,7 +8909,7 @@ export class Databases { * @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. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7613,7 +8918,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; createDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7621,16 +8926,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7642,14 +8947,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7694,7 +8999,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7704,7 +9038,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. @@ -7715,7 +9049,7 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7724,7 +9058,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7733,7 +9067,7 @@ export class Databases { databaseId: string, collectionId: string, documents: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7741,16 +9075,16 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7762,14 +9096,14 @@ export class Databases { databaseId: string; collectionId: string; documents: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -7814,7 +9148,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7824,7 +9187,7 @@ export class Databases { * @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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. @@ -7836,7 +9199,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.DocumentList<Document>>; /** * 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. @@ -7845,7 +9208,7 @@ export class Databases { * @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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7855,7 +9218,7 @@ export class Databases { collectionId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.DocumentList<Document>>; updateDocuments<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -7864,17 +9227,17 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.DocumentList<Document>> { let params: { databaseId: string; collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -7887,7 +9250,7 @@ export class Databases { collectionId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -7895,7 +9258,7 @@ export class Databases { 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 | null, }; } @@ -7939,7 +9302,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8052,7 +9444,36 @@ export class Databases { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8182,7 +9603,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8192,8 +9631,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. @@ -8208,8 +9647,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * 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. @@ -8218,8 +9657,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include all required attributes 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8232,8 +9671,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; upsertDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8245,8 +9684,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8256,8 +9695,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8268,8 +9707,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8285,8 +9724,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8297,8 +9736,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8352,7 +9791,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8362,8 +9819,8 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} params.data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead. @@ -8378,8 +9835,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Document>; /** * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -8388,8 +9845,8 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} documentId - Document ID. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>} data - Document data as JSON object. Include only attribute 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8402,8 +9859,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Document>; updateDocument<Document extends Models.Document = Models.DefaultDocument>( paramsOrFirst: @@ -8415,8 +9872,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8426,8 +9883,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Document> { let params: { @@ -8438,8 +9895,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8455,8 +9912,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8467,8 +9924,8 @@ export class Databases { ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Partial<Omit<Document, keyof Models.Document>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8522,7 +9979,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8650,8 +10125,8 @@ export class Databases { * @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.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. + * @param {number | null} params.min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead. @@ -8664,8 +10139,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Decrement a specific attribute of a document by a given value. @@ -8675,8 +10150,8 @@ export class Databases { * @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} 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. + * @param {number | null} min - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8689,8 +10164,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Document>; decrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8702,11 +10177,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8714,8 +10196,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -8729,8 +10211,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8739,8 +10221,8 @@ export class Databases { 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, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8798,7 +10280,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8809,8 +10309,8 @@ export class Databases { * @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. + * @param {number | null} params.max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead. @@ -8823,8 +10323,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Document>; /** * Increment a specific attribute of a document by a given value. @@ -8834,8 +10334,8 @@ export class Databases { * @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. + * @param {number | null} max - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8848,8 +10348,8 @@ export class Databases { documentId: string, attribute: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Document>; incrementDocumentAttribute< Document extends Models.Document = Models.DefaultDocument, @@ -8861,11 +10361,18 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Document> { let params: { databaseId: string; @@ -8873,8 +10380,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -8888,8 +10395,8 @@ export class Databases { documentId: string; attribute: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -8898,8 +10405,8 @@ export class Databases { 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, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -8957,7 +10464,25 @@ export class Databases { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9067,12 +10592,42 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9096,7 +10651,7 @@ export class Databases { }): Promise<Models.Index>; /** * 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`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use 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). @@ -9234,7 +10789,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9324,7 +10898,26 @@ export class Databases { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 823cf87..8d1f7f6 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DocumentsDBIndexType } from '../enums/documents-db-index-type'; @@ -72,7 +77,69 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class DocumentsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class DocumentsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class DocumentsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class DocumentsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class DocumentsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class DocumentsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class DocumentsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,58 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collectionList', + models: { + collectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'collection', + }, + }, + }, + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1384,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -988,7 +1396,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1000,7 +1408,7 @@ export class DocumentsDB { * @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 {string[] | null} 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. @@ -1013,7 +1421,7 @@ export class DocumentsDB { databaseId: string, collectionId: string, name: string, - permissions?: string[], + permissions?: string[] | null, documentSecurity?: boolean, enabled?: boolean, attributes?: object[], @@ -1025,7 +1433,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1035,7 +1443,7 @@ export class DocumentsDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1046,7 +1454,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1062,7 +1470,7 @@ export class DocumentsDB { databaseId: string; collectionId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; documentSecurity?: boolean; enabled?: boolean; attributes?: object[]; @@ -1073,7 +1481,7 @@ export class DocumentsDB { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, documentSecurity: rest[3] as boolean, enabled: rest[4] as boolean, attributes: rest[5] as object[], @@ -1136,7 +1544,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1212,7 +1660,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1360,7 +1848,47 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'collection', + models: { + collection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1569,7 +2097,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1738,7 +2295,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1855,7 +2430,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1974,7 +2578,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2731,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2210,7 +2872,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2339,7 +3030,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2508,7 +3217,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2677,7 +3404,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2951,7 +3696,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3109,7 +3872,25 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3218,7 +3999,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3384,7 +4195,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3473,7 +4303,26 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3570,33 +4419,33 @@ export class DocumentsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3605,12 +4454,12 @@ export class DocumentsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3637,7 +4486,63 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3741,7 +4646,37 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3798,7 +4733,36 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3853,6 +4817,51 @@ export class DocumentsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/domains.ts b/src/services/domains.ts index 7550437..12834f0 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { DomainRegistrationType } from '../enums/domain-registration-type'; @@ -71,7 +76,62 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainsList', + models: { + domainsList: { + defaults: { + total: 0, + domains: [], + }, + properties: { + domains: { + items: 'domain', + }, + }, + }, + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -139,7 +199,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +334,24 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPrice', + models: { + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -322,7 +443,35 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainPricesList', + models: { + domainPricesList: { + defaults: { + total: 0, + prices: [], + }, + properties: { + prices: { + items: 'domainPrice', + }, + }, + }, + domainPrice: { + defaults: { + domain: '', + tld: '', + available: false, + periodYears: 1, + premium: false, + renewalPeriodYears: 1, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -375,7 +524,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -506,7 +699,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +803,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -623,7 +904,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -685,7 +1000,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +1091,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -802,7 +1185,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -859,7 +1276,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -919,7 +1370,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -976,7 +1461,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1036,7 +1555,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1093,7 +1646,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1153,7 +1740,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1208,7 +1829,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1268,7 +1923,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1342,7 +2031,41 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecordsList', + models: { + dnsRecordsList: { + defaults: { + total: 0, + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1470,7 +2193,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1613,7 +2359,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1741,7 +2510,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1884,7 +2676,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2014,7 +2829,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2161,7 +2999,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2289,7 +3150,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2432,7 +3316,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2566,7 +3473,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3635,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2833,7 +3786,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2976,7 +3952,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3125,7 +4124,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3281,7 +4303,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3409,7 +4454,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3554,7 +4622,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3731,7 +4822,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3952,7 +5066,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4079,7 +5216,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4224,7 +5384,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4302,7 +5485,30 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dnsRecord', + models: { + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4453,7 +5659,51 @@ export class Domains { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4510,7 +5760,21 @@ export class Domains { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domainTransferStatus', + models: { + domainTransferStatus: { + defaults: { + status: 'pending_registry', + reason: '', + timestamp: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4642,6 +5906,50 @@ export class Domains { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'domain', + models: { + domain: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + registrar: '', + nameservers: '', + expire: '', + renewal: '', + autoRenewal: false, + renewalPrice: 0, + teamId: '', + dnsRecords: [], + }, + properties: { + dnsRecords: { + items: 'dnsRecord', + }, + }, + }, + dnsRecord: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + name: '', + value: '', + ttl: 3600, + priority: 0, + lock: false, + weight: 0, + port: 0, + comment: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/embeddings.ts b/src/services/embeddings.ts index ff08ad9..baf425d 100644 --- a/src/services/embeddings.ts +++ b/src/services/embeddings.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { EmbeddingModel } from '../enums/embedding-model'; @@ -79,6 +84,32 @@ export class Embeddings { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'embeddingList', + models: { + embeddingList: { + defaults: { + total: 0, + embeddings: [], + }, + properties: { + embeddings: { + items: 'embedding', + }, + }, + }, + embedding: { + defaults: { + model: '', + dimension: 0, + embedding: [], + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/functions.ts b/src/services/functions.ts index 8af9565..75e54d4 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -96,7 +97,79 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'functionList', + models: { + functionList: { + defaults: { + total: 0, + functions: [], + }, + properties: { + functions: { + items: 'function', + }, + }, + }, + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -107,7 +180,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +197,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -150,6 +224,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise<Models.Function>; /** * 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. @@ -159,7 +234,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +251,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +279,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise<Models.Function>; create( paramsOrFirst: @@ -229,6 +306,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +331,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise<Models.Function> { let params: { @@ -278,6 +357,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +388,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +414,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +440,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +522,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -447,7 +533,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -498,7 +645,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'runtimeList', + models: { + runtimeList: { + defaults: { + total: 0, + runtimes: [], + }, + properties: { + runtimes: { + items: 'runtime', + }, + }, + }, + runtime: { + defaults: { + $id: '', + key: '', + name: '', + version: '', + base: '', + image: '', + logo: '', + supports: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -566,7 +743,33 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -621,7 +824,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -632,7 +896,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -640,15 +904,17 @@ export class Functions { * @param {string} params.commands - Build Commands. * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the function deployments. - * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} params.buildSpecification - Build specification for the function deployments. + * @param {string | null} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} params.emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ @@ -666,15 +932,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }): Promise<Models.Function>; /** * Update function by its unique ID. @@ -684,7 +952,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -692,15 +960,17 @@ export class Functions { * @param {string} commands - Build Commands. * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the function deployments. - * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} buildSpecification - Build specification for the function deployments. + * @param {string | null} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number | null} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + * @param {boolean | null} emailEnabled - Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. * @throws {AppwriteException} * @returns {Promise<Models.Function>} * @deprecated Use the object parameter style method for a better developer experience. @@ -719,15 +989,17 @@ export class Functions { commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, - runtimeSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, + runtimeSpecification?: string | null, deploymentRetention?: number, + interval?: number | null, + emailEnabled?: boolean | null, ): Promise<Models.Function>; update( paramsOrFirst: @@ -745,15 +1017,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; } | string, ...rest: [ @@ -769,15 +1043,17 @@ export class Functions { string?, ProjectKeyScopes[]?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, number?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.Function> { let params: { @@ -794,15 +1070,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; if ( @@ -824,15 +1102,17 @@ export class Functions { commands?: string; scopes?: ProjectKeyScopes[]; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; - runtimeSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; + runtimeSpecification?: string | null; deploymentRetention?: number; + interval?: number | null; + emailEnabled?: boolean | null; }; } else { params = { @@ -849,15 +1129,17 @@ export class Functions { commands: rest[9] as string, scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, - providerRepositoryId: rest[12] as string, + providerRepositoryId: rest[12] as string | null, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - providerBranches: rest[16] as string[], - providerPaths: rest[17] as string[], - buildSpecification: rest[18] as string, - runtimeSpecification: rest[19] as string, + providerBranches: rest[16] as string[] | null, + providerPaths: rest[17] as string[] | null, + buildSpecification: rest[18] as string | null, + runtimeSpecification: rest[19] as string | null, deploymentRetention: rest[20] as number, + interval: rest[21] as number | null, + emailEnabled: rest[22] as boolean | null, }; } @@ -883,6 +1165,8 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; + const emailEnabled = params.emailEnabled; if (typeof functionId === 'undefined' || functionId === '') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -959,6 +1243,12 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof emailEnabled !== 'undefined') { + apiPayload['emailEnabled'] = emailEnabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -967,7 +1257,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1099,7 +1450,68 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'function', + models: { + function: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + execute: [], + name: '', + enabled: true, + live: true, + logging: true, + runtime: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + events: [], + schedule: '', + timeout: 15, + entrypoint: '', + commands: '', + version: 'v5', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: false, + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1203,7 +1615,55 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1450,7 +1910,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1623,7 +2120,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1740,7 +2274,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1816,7 +2387,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2691,44 @@ export class Functions { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2167,7 +2812,59 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2876,7 @@ export class Functions { * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ @@ -2190,7 +2887,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Execution>; /** * 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. @@ -2201,7 +2898,7 @@ export class Functions { * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string | null} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @throws {AppwriteException} * @returns {Promise<Models.Execution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2213,7 +2910,7 @@ export class Functions { xpath?: string, method?: ExecutionMethod, headers?: object, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Execution>; createExecution( paramsOrFirst: @@ -2224,7 +2921,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; } | string, ...rest: [ @@ -2233,7 +2930,7 @@ export class Functions { string?, ExecutionMethod?, object?, - string?, + (string | null)?, ] ): Promise<Models.Execution> { let params: { @@ -2243,7 +2940,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -2258,7 +2955,7 @@ export class Functions { xpath?: string; method?: ExecutionMethod; headers?: object; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -2268,7 +2965,7 @@ 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 | null, }; } @@ -2315,7 +3012,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2388,7 +3126,48 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2543,7 +3322,37 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2671,7 +3480,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3572,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2752,27 +3599,27 @@ export class Functions { * * @param {string} params.functionId - Function unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId - Function unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2780,28 +3627,33 @@ export class Functions { updateVariable( functionId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2812,17 +3664,17 @@ export class Functions { params = (paramsOrFirst || {}) as { functionId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2862,7 +3714,26 @@ export class Functions { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/locale.ts b/src/services/locale.ts index 949a1e5..ca069ee 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,4 +1,4 @@ -import { Client, type Payload } from '../client'; +import { Client, type Payload, applyDefaults } from '../client'; import type { Models } from '../models'; export class Locale { @@ -26,7 +26,25 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'locale', + models: { + locale: { + defaults: { + ip: '', + countryCode: '', + country: '', + continentCode: '', + continent: '', + eu: false, + currency: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -77,7 +95,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'localeCodeList', + models: { + localeCodeList: { + defaults: { + total: 0, + localeCodes: [], + }, + properties: { + localeCodes: { + items: 'localeCode', + }, + }, + }, + localeCode: { + defaults: { + code: '', + name: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -128,7 +170,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'continentList', + models: { + continentList: { + defaults: { + total: 0, + continents: [], + }, + properties: { + continents: { + items: 'continent', + }, + }, + }, + continent: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -179,7 +245,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +320,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'countryList', + models: { + countryList: { + defaults: { + total: 0, + countries: [], + }, + properties: { + countries: { + items: 'country', + }, + }, + }, + country: { + defaults: { + name: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -283,7 +397,32 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'phoneList', + models: { + phoneList: { + defaults: { + total: 0, + phones: [], + }, + properties: { + phones: { + items: 'phone', + }, + }, + }, + phone: { + defaults: { + code: '', + countryCode: '', + countryName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -334,7 +473,36 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'currencyList', + models: { + currencyList: { + defaults: { + total: 0, + currencies: [], + }, + properties: { + currencies: { + items: 'currency', + }, + }, + }, + currency: { + defaults: { + symbol: '', + name: '', + symbolNative: '', + decimalDigits: 0, + rounding: 0, + code: '', + namePlural: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -385,6 +553,31 @@ export class Locale { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'languageList', + models: { + languageList: { + defaults: { + total: 0, + languages: [], + }, + properties: { + languages: { + items: 'language', + }, + }, + }, + language: { + defaults: { + name: '', + code: '', + nativeName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2225646..4ea6d8c 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; @@ -86,7 +91,39 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'messageList', + models: { + messageList: { + defaults: { + total: 0, + messages: [], + }, + properties: { + messages: { + items: 'message', + }, + }, + }, + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,12 +137,12 @@ export class Messaging { * @param {string[]} params.targets - List of Targets IDs. * @param {string[]} params.cc - Array of target IDs to be added as CC. * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} params.draft - Is message a draft * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} params.replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} params.replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -118,12 +155,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }): Promise<Models.Message>; /** * Create a new email message. @@ -136,12 +173,12 @@ export class Messaging { * @param {string[]} targets - List of Targets IDs. * @param {string[]} cc - Array of target IDs to be added as CC. * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. - * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {boolean} draft - Is message a draft * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string} replyToEmail - Email address to reply to. If not set, defaults to the sender email address. + * @param {string} replyToName - Name of the reply to recipient. If not set, defaults to the sender name. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -155,12 +192,12 @@ export class Messaging { targets?: string[], cc?: string[], bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, + attachments?: string[] | null, draft?: boolean, html?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, + replyToEmail?: string, + replyToName?: string, ): Promise<Models.Message>; createEmail( paramsOrFirst: @@ -173,12 +210,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; } | string, ...rest: [ @@ -189,11 +226,11 @@ export class Messaging { string[]?, string[]?, string[]?, - string[]?, - string?, - string?, + (string[] | null)?, boolean?, boolean?, + (string | null)?, + string?, string?, ] ): Promise<Models.Message> { @@ -206,12 +243,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; if ( @@ -228,12 +265,12 @@ export class Messaging { targets?: string[]; cc?: string[]; bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; + attachments?: string[] | null; draft?: boolean; html?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; + replyToEmail?: string; + replyToName?: string; }; } else { params = { @@ -245,12 +282,12 @@ export class Messaging { targets: rest[4] as string[], cc: rest[5] as string[], bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + attachments: rest[7] as string[] | null, + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string | null, + replyToEmail: rest[11] as string, + replyToName: rest[12] as string, }; } @@ -263,11 +300,11 @@ export class Messaging { const cc = params.cc; const bcc = params.bcc; const attachments = params.attachments; - const replyToEmail = params.replyToEmail; - const replyToName = params.replyToName; const draft = params.draft; const html = params.html; const scheduledAt = params.scheduledAt; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; if (typeof messageId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -312,12 +349,6 @@ export class Messaging { if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } - if (typeof replyToEmail !== 'undefined') { - apiPayload['replyToEmail'] = replyToEmail; - } - if (typeof replyToName !== 'undefined') { - apiPayload['replyToName'] = replyToName; - } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -327,6 +358,12 @@ export class Messaging { if (typeof scheduledAt !== 'undefined') { apiPayload['scheduledAt'] = scheduledAt; } + if (typeof replyToEmail !== 'undefined') { + apiPayload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + apiPayload['replyToName'] = replyToName; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -335,7 +372,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,126 +401,126 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.subject - Email Subject. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {string[]} params.cc - Array of target IDs to be added as CC. - * @param {string[]} params.bcc - Array of target IDs to be added as BCC. - * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} params.draft - Is message a draft - * @param {boolean} params.html - Is content of type HTML - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.subject - Email Subject. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {boolean | null} params.html - Is content of type HTML + * @param {string[] | null} params.cc - Array of target IDs to be added as CC. + * @param {string[] | null} params.bcc - Array of target IDs to be added as BCC. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} params.replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.Message>; /** * 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} subject - Email Subject. - * @param {string} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {string[]} cc - Array of target IDs to be added as CC. - * @param {string[]} bcc - Array of target IDs to be added as BCC. - * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. - * @param {string} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. - * @param {boolean} draft - Is message a draft - * @param {boolean} html - Is content of type HTML - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} subject - Email Subject. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {boolean | null} html - Is content of type HTML + * @param {string[] | null} cc - Array of target IDs to be added as CC. + * @param {string[] | null} bcc - Array of target IDs to be added as BCC. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} replyToEmail - Email address to reply to. Pass an empty string to restore the provider or sender default. + * @param {string | null} replyToName - Name of the reply to recipient. Pass an empty string to restore the provider or sender default. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateEmail( messageId: string, - subject?: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - cc?: string[], - bcc?: string[], - attachments?: string[], - replyToEmail?: string, - replyToName?: string, - draft?: boolean, - html?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + subject?: string | null, + content?: string | null, + draft?: boolean | null, + html?: boolean | null, + cc?: string[] | null, + bcc?: string[] | null, + scheduledAt?: string | null, + attachments?: string[] | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.Message>; updateEmail( paramsOrFirst: | { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string[]?, - string?, - string?, - boolean?, - boolean?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.Message> { let params: { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -472,53 +530,53 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - subject?: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - cc?: string[]; - bcc?: string[]; - attachments?: string[]; - replyToEmail?: string; - replyToName?: string; - draft?: boolean; - html?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + subject?: string | null; + content?: string | null; + draft?: boolean | null; + html?: boolean | null; + cc?: string[] | null; + bcc?: string[] | null; + scheduledAt?: string | null; + attachments?: string[] | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - subject: rest[0] as string, - content: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - cc: rest[5] as string[], - bcc: rest[6] as string[], - attachments: rest[7] as string[], - replyToEmail: rest[8] as string, - replyToName: rest[9] as string, - draft: rest[10] as boolean, - html: rest[11] as boolean, - scheduledAt: rest[12] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + subject: rest[3] as string | null, + content: rest[4] as string | null, + draft: rest[5] as boolean | null, + html: rest[6] as boolean | null, + cc: rest[7] as string[] | null, + bcc: rest[8] as string[] | null, + scheduledAt: rest[9] as string | null, + attachments: rest[10] as string[] | null, + replyToEmail: rest[11] as string | null, + replyToName: rest[12] as string | null, }; } const messageId = params.messageId; - const subject = params.subject; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; const cc = params.cc; const bcc = params.bcc; + const scheduledAt = params.scheduledAt; const attachments = params.attachments; const replyToEmail = params.replyToEmail; const replyToName = params.replyToName; - const draft = params.draft; - const html = params.html; - const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { throw new AppwriteException( 'Missing required parameter: "messageId"', @@ -529,12 +587,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof subject !== 'undefined') { - apiPayload['subject'] = subject; - } - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -544,12 +596,27 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof subject !== 'undefined') { + apiPayload['subject'] = subject; + } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } + if (typeof draft !== 'undefined') { + apiPayload['draft'] = draft; + } + if (typeof html !== 'undefined') { + apiPayload['html'] = html; + } if (typeof cc !== 'undefined') { apiPayload['cc'] = cc; } if (typeof bcc !== 'undefined') { apiPayload['bcc'] = bcc; } + if (typeof scheduledAt !== 'undefined') { + apiPayload['scheduledAt'] = scheduledAt; + } if (typeof attachments !== 'undefined') { apiPayload['attachments'] = attachments; } @@ -559,15 +626,6 @@ export class Messaging { if (typeof replyToName !== 'undefined') { apiPayload['replyToName'] = replyToName; } - if (typeof draft !== 'undefined') { - apiPayload['draft'] = draft; - } - if (typeof html !== 'undefined') { - apiPayload['html'] = html; - } - if (typeof scheduledAt !== 'undefined') { - apiPayload['scheduledAt'] = scheduledAt; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -576,7 +634,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -588,7 +667,7 @@ export class Messaging { * @param {string[]} params.topics - List of Topic IDs. * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional key-value pair data for push notification. + * @param {object | null} params.data - Additional key-value pair data for push notification. * @param {string} params.action - Action for push notification. * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. @@ -597,7 +676,7 @@ export class Messaging { * @param {string} params.tag - Tag for push notification. Available only for Android Platform. * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -612,7 +691,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -621,7 +700,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -636,7 +715,7 @@ export class Messaging { * @param {string[]} topics - List of Topic IDs. * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional key-value pair data for push notification. + * @param {object | null} data - Additional key-value pair data for push notification. * @param {string} action - Action for push notification. * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. @@ -645,7 +724,7 @@ export class Messaging { * @param {string} tag - Tag for push notification. Available only for Android Platform. * @param {number} badge - Badge for push notification. Available only for iOS Platform. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. @@ -661,7 +740,7 @@ export class Messaging { topics?: string[], users?: string[], targets?: string[], - data?: object, + data?: object | null, action?: string, image?: string, icon?: string, @@ -670,7 +749,7 @@ export class Messaging { tag?: string, badge?: number, draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority, @@ -685,7 +764,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -694,7 +773,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -707,7 +786,7 @@ export class Messaging { string[]?, string[]?, string[]?, - object?, + (object | null)?, string?, string?, string?, @@ -716,7 +795,7 @@ export class Messaging { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, MessagePriority?, @@ -730,7 +809,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -739,7 +818,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -758,7 +837,7 @@ export class Messaging { topics?: string[]; users?: string[]; targets?: string[]; - data?: object; + data?: object | null; action?: string; image?: string; icon?: string; @@ -767,7 +846,7 @@ export class Messaging { tag?: string; badge?: number; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; contentAvailable?: boolean; critical?: boolean; priority?: MessagePriority; @@ -781,7 +860,7 @@ export class Messaging { topics: rest[2] as string[], users: rest[3] as string[], targets: rest[4] as string[], - data: rest[5] as object, + data: rest[5] as object | null, action: rest[6] as string, image: rest[7] as string, icon: rest[8] as string, @@ -790,7 +869,7 @@ export class Messaging { tag: rest[11] as string, badge: rest[12] as number, draft: rest[13] as boolean, - scheduledAt: rest[14] as string, + scheduledAt: rest[14] as string | null, contentAvailable: rest[15] as boolean, critical: rest[16] as boolean, priority: rest[17] as MessagePriority, @@ -893,7 +972,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -901,168 +1001,168 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.title - Title for push notification. - * @param {string} params.body - Body for push notification. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {object} params.data - Additional Data for push notification. - * @param {string} params.action - Action for push notification. - * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} params.color - Color for push notification. Available only for Android platforms. - * @param {string} params.tag - Tag for push notification. Available only for Android platforms. - * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.title - Title for push notification. + * @param {string | null} params.body - Body for push notification. + * @param {object | null} params.data - Additional Data for push notification. + * @param {string | null} params.action - Action for push notification. + * @param {string | null} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} params.color - Color for push notification. Available only for Android platforms. + * @param {string | null} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} params.channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }): Promise<Models.Message>; /** * 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} title - Title for push notification. - * @param {string} body - Body for push notification. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {object} data - Additional Data for push notification. - * @param {string} action - Action for push notification. - * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. - * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. - * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. - * @param {string} color - Color for push notification. Available only for Android platforms. - * @param {string} tag - Tag for push notification. Available only for Android platforms. - * @param {number} badge - Badge for push notification. Available only for iOS platforms. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. - * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. - * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. - * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. - * @param {string} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} title - Title for push notification. + * @param {string | null} body - Body for push notification. + * @param {object | null} data - Additional Data for push notification. + * @param {string | null} action - Action for push notification. + * @param {string | null} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string | null} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string | null} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string | null} color - Color for push notification. Available only for Android platforms. + * @param {string | null} tag - Tag for push notification. Available only for Android platforms. + * @param {number | null} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean | null} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean | null} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority | null} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @param {string | null} channelId - ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updatePush( 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, - channelId?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + title?: string | null, + body?: string | null, + data?: object | null, + action?: string | null, + image?: string | null, + icon?: string | null, + sound?: string | null, + color?: string | null, + tag?: string | null, + badge?: number | null, + draft?: boolean | null, + scheduledAt?: string | null, + contentAvailable?: boolean | null, + critical?: boolean | null, + priority?: MessagePriority | null, + channelId?: string | null, ): Promise<Models.Message>; updatePush( 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; } | string, ...rest: [ - string?, - string?, - string[]?, - string[]?, - string[]?, - object?, - string?, - string?, - string?, - string?, - string?, - string?, - number?, - boolean?, - string?, - boolean?, - boolean?, - MessagePriority?, - string?, + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (string | null)?, + (object | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (boolean | null)?, + (boolean | null)?, + (MessagePriority | null)?, + (string | null)?, ] ): Promise<Models.Message> { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; if ( @@ -1072,57 +1172,57 @@ export class Messaging { ) { 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; - channelId?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + title?: string | null; + body?: string | null; + data?: object | null; + action?: string | null; + image?: string | null; + icon?: string | null; + sound?: string | null; + color?: string | null; + tag?: string | null; + badge?: number | null; + draft?: boolean | null; + scheduledAt?: string | null; + contentAvailable?: boolean | null; + critical?: boolean | null; + priority?: MessagePriority | null; + channelId?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - title: rest[0] as string, - body: rest[1] as string, - topics: rest[2] as string[], - users: rest[3] as string[], - targets: rest[4] as string[], - data: rest[5] as object, - action: rest[6] as string, - image: rest[7] as string, - icon: rest[8] as string, - sound: rest[9] as string, - color: rest[10] as string, - tag: rest[11] as string, - badge: rest[12] as number, - draft: rest[13] as boolean, - scheduledAt: rest[14] as string, - contentAvailable: rest[15] as boolean, - critical: rest[16] as boolean, - priority: rest[17] as MessagePriority, - channelId: rest[18] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + title: rest[3] as string | null, + body: rest[4] as string | null, + data: rest[5] as object | null, + action: rest[6] as string | null, + image: rest[7] as string | null, + icon: rest[8] as string | null, + sound: rest[9] as string | null, + color: rest[10] as string | null, + tag: rest[11] as string | null, + badge: rest[12] as number | null, + draft: rest[13] as boolean | null, + scheduledAt: rest[14] as string | null, + contentAvailable: rest[15] as boolean | null, + critical: rest[16] as boolean | null, + priority: rest[17] as MessagePriority | null, + channelId: rest[18] as string | null, }; } const messageId = params.messageId; - const title = params.title; - const body = params.body; const topics = params.topics; const users = params.users; const targets = params.targets; + const title = params.title; + const body = params.body; const data = params.data; const action = params.action; const image = params.image; @@ -1147,12 +1247,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof title !== 'undefined') { - apiPayload['title'] = title; - } - if (typeof body !== 'undefined') { - apiPayload['body'] = body; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1162,6 +1256,12 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof title !== 'undefined') { + apiPayload['title'] = title; + } + if (typeof body !== 'undefined') { + apiPayload['body'] = body; + } if (typeof data !== 'undefined') { apiPayload['data'] = data; } @@ -1212,7 +1312,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1224,7 +1345,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. @@ -1236,7 +1357,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1247,7 +1368,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1259,7 +1380,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSms( paramsOrFirst: @@ -1270,10 +1391,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1282,7 +1410,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1297,7 +1425,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1307,7 +1435,7 @@ 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 | null, }; } @@ -1359,7 +1487,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1371,7 +1520,7 @@ export class Messaging { * @param {string[]} params.users - List of User IDs. * @param {string[]} params.targets - List of Targets IDs. * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ @@ -1382,7 +1531,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * Create a new SMS message. @@ -1393,7 +1542,7 @@ export class Messaging { * @param {string[]} users - List of User IDs. * @param {string[]} targets - List of Targets IDs. * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1405,7 +1554,7 @@ export class Messaging { users?: string[], targets?: string[], draft?: boolean, - scheduledAt?: string, + scheduledAt?: string | null, ): Promise<Models.Message>; createSMS( paramsOrFirst: @@ -1416,10 +1565,17 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + string?, + string[]?, + string[]?, + string[]?, + boolean?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; @@ -1428,7 +1584,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; if ( @@ -1443,7 +1599,7 @@ export class Messaging { users?: string[]; targets?: string[]; draft?: boolean; - scheduledAt?: string; + scheduledAt?: string | null; }; } else { params = { @@ -1453,7 +1609,7 @@ 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 | null, }; } @@ -1505,7 +1661,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1513,71 +1690,78 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. */ updateSms(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSms( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSms( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1587,30 +1771,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1623,9 +1807,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1635,6 +1816,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1649,7 +1833,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1657,70 +1862,77 @@ export class Messaging { * * * @param {string} params.messageId - Message ID. - * @param {string} params.content - Email Content. - * @param {string[]} params.topics - List of Topic IDs. - * @param {string[]} params.users - List of User IDs. - * @param {string[]} params.targets - List of Targets IDs. - * @param {boolean} params.draft - Is message a draft - * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} params.topics - List of Topic IDs. + * @param {string[] | null} params.users - List of User IDs. + * @param {string[] | null} params.targets - List of Targets IDs. + * @param {string | null} params.content - Email Content. + * @param {boolean | null} params.draft - Is message a draft + * @param {string | null} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSMS(params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }): Promise<Models.Message>; /** * 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} content - Email Content. - * @param {string[]} topics - List of Topic IDs. - * @param {string[]} users - List of User IDs. - * @param {string[]} targets - List of Targets IDs. - * @param {boolean} draft - Is message a draft - * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[] | null} topics - List of Topic IDs. + * @param {string[] | null} users - List of User IDs. + * @param {string[] | null} targets - List of Targets IDs. + * @param {string | null} content - Email Content. + * @param {boolean | null} draft - Is message a draft + * @param {string | null} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @throws {AppwriteException} * @returns {Promise<Models.Message>} * @deprecated Use the object parameter style method for a better developer experience. */ updateSMS( messageId: string, - content?: string, - topics?: string[], - users?: string[], - targets?: string[], - draft?: boolean, - scheduledAt?: string, + topics?: string[] | null, + users?: string[] | null, + targets?: string[] | null, + content?: string | null, + draft?: boolean | null, + scheduledAt?: string | null, ): Promise<Models.Message>; updateSMS( paramsOrFirst: | { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; } | string, - ...rest: [string?, string[]?, string[]?, string[]?, boolean?, string?] + ...rest: [ + (string[] | null)?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.Message> { let params: { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; if ( @@ -1730,30 +1942,30 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { messageId: string; - content?: string; - topics?: string[]; - users?: string[]; - targets?: string[]; - draft?: boolean; - scheduledAt?: string; + topics?: string[] | null; + users?: string[] | null; + targets?: string[] | null; + content?: string | null; + draft?: boolean | null; + scheduledAt?: string | null; }; } else { params = { messageId: paramsOrFirst as string, - content: rest[0] as string, - topics: rest[1] as string[], - users: rest[2] as string[], - targets: rest[3] as string[], - draft: rest[4] as boolean, - scheduledAt: rest[5] as string, + topics: rest[0] as string[] | null, + users: rest[1] as string[] | null, + targets: rest[2] as string[] | null, + content: rest[3] as string | null, + draft: rest[4] as boolean | null, + scheduledAt: rest[5] as string | null, }; } const messageId = params.messageId; - const content = params.content; const topics = params.topics; const users = params.users; const targets = params.targets; + const content = params.content; const draft = params.draft; const scheduledAt = params.scheduledAt; if (typeof messageId === 'undefined' || messageId === '') { @@ -1766,9 +1978,6 @@ export class Messaging { encodeURIComponent(String(messageId)), ); const apiPayload: Payload = {}; - if (typeof content !== 'undefined') { - apiPayload['content'] = content; - } if (typeof topics !== 'undefined') { apiPayload['topics'] = topics; } @@ -1778,6 +1987,9 @@ export class Messaging { if (typeof targets !== 'undefined') { apiPayload['targets'] = targets; } + if (typeof content !== 'undefined') { + apiPayload['content'] = content; + } if (typeof draft !== 'undefined') { apiPayload['draft'] = draft; } @@ -1792,7 +2004,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1849,7 +2082,28 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'message', + models: { + message: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + providerType: '', + topics: [], + users: [], + targets: [], + deliveredTotal: 0, + data: {}, + status: 'draft', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1986,7 +2240,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2065,7 +2349,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'providerList', + models: { + providerList: { + defaults: { + total: 0, + providers: [], + }, + properties: { + providers: { + items: 'provider', + }, + }, + }, + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2078,7 +2392,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. @@ -2091,7 +2405,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2103,7 +2417,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2116,7 +2430,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createApnsProvider( paramsOrFirst: @@ -2128,7 +2442,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2138,7 +2452,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2149,7 +2463,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2165,7 +2479,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2176,7 +2490,7 @@ 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 | null, }; } @@ -2230,7 +2544,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2243,7 +2576,7 @@ export class Messaging { * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -2255,7 +2588,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Apple Push Notification service provider. @@ -2267,7 +2600,7 @@ export class Messaging { * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2280,7 +2613,7 @@ export class Messaging { teamId?: string, bundleId?: string, sandbox?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createAPNSProvider( paramsOrFirst: @@ -2292,7 +2625,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -2302,7 +2635,7 @@ export class Messaging { string?, string?, boolean?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -2313,7 +2646,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -2329,7 +2662,7 @@ export class Messaging { teamId?: string; bundleId?: string; sandbox?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -2340,7 +2673,7 @@ 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 | null, }; } @@ -2394,7 +2727,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2402,12 +2754,12 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. @@ -2415,24 +2767,24 @@ export class Messaging { updateApnsProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2440,45 +2792,45 @@ export class Messaging { updateApnsProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateApnsProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2489,23 +2841,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2556,7 +2908,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2564,36 +2935,36 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. - * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean | null} params.sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAPNSProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }): Promise<Models.Provider>; /** * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. - * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean | null} sandbox - Use APNS sandbox environment. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2601,45 +2972,45 @@ export class Messaging { updateAPNSProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, - sandbox?: boolean, + sandbox?: boolean | null, ): Promise<Models.Provider>; updateAPNSProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; } | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; if ( @@ -2650,23 +3021,23 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; authKey?: string; authKeyId?: string; teamId?: string; bundleId?: string; - sandbox?: boolean; + sandbox?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, authKey: rest[2] as string, 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 | null, }; } @@ -2717,7 +3088,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2725,27 +3115,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createAppwriteProvider(params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Create a new Appwrite push provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2753,28 +3143,33 @@ export class Messaging { createAppwriteProvider( providerId: string, name: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; createAppwriteProvider( paramsOrFirst: | { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2785,17 +3180,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2837,7 +3232,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,27 +3259,27 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {number} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} params.enabled - Set as enabled. + * @param {number | null} params.qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} params.expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateAppwriteProvider(params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Provider>; /** * Update an Appwrite push provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {number} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - * @param {number} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). + * @param {boolean | null} enabled - Set as enabled. + * @param {number | null} qos - Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + * @param {number | null} expiry - Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2873,28 +3287,33 @@ export class Messaging { updateAppwriteProvider( providerId: string, name?: string, - enabled?: boolean, - qos?: number, - expiry?: number, + enabled?: boolean | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Provider>; updateAppwriteProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, boolean?, number?, number?] + ...rest: [ + string?, + (boolean | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -2905,17 +3324,17 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - qos?: number; - expiry?: number; + enabled?: boolean | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - qos: rest[2] as number, - expiry: rest[3] as number, + enabled: rest[1] as boolean | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -2954,7 +3373,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2962,8 +3400,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. @@ -2971,16 +3409,16 @@ export class Messaging { createFcmProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2988,25 +3426,25 @@ export class Messaging { createFcmProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFcmProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3017,15 +3455,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3063,7 +3501,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3071,24 +3528,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. - * @param {boolean} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFCMProvider(params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. - * @param {boolean} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3096,25 +3553,25 @@ export class Messaging { createFCMProvider( providerId: string, name: string, - serviceAccountJSON?: object, - enabled?: boolean, + serviceAccountJSON?: object | null, + enabled?: boolean | null, ): Promise<Models.Provider>; createFCMProvider( paramsOrFirst: | { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; } | string, - ...rest: [string?, object?, boolean?] + ...rest: [string?, (object | null)?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; if ( @@ -3125,15 +3582,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name: string; - serviceAccountJSON?: object; - enabled?: boolean; + serviceAccountJSON?: object | null; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean, + serviceAccountJSON: rest[1] as object | null, + enabled: rest[2] as boolean | null, }; } @@ -3171,7 +3628,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3179,8 +3655,8 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. @@ -3188,16 +3664,16 @@ export class Messaging { updateFcmProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3205,25 +3681,25 @@ export class Messaging { updateFcmProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFcmProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3234,15 +3710,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3277,7 +3753,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3285,24 +3780,24 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} params.enabled - Set as enabled. + * @param {object | null} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFCMProvider(params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean | null} enabled - Set as enabled. + * @param {object | null} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3310,25 +3805,25 @@ export class Messaging { updateFCMProvider( providerId: string, name?: string, - enabled?: boolean, - serviceAccountJSON?: object, + enabled?: boolean | null, + serviceAccountJSON?: object | null, ): Promise<Models.Provider>; updateFCMProvider( paramsOrFirst: | { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; } | string, - ...rest: [string?, boolean?, object?] + ...rest: [string?, (boolean | null)?, (object | null)?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; if ( @@ -3339,15 +3834,15 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; - serviceAccountJSON?: object; + enabled?: boolean | null; + serviceAccountJSON?: object | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - serviceAccountJSON: rest[2] as object, + enabled: rest[1] as boolean | null, + serviceAccountJSON: rest[2] as object | null, }; } @@ -3382,7 +3877,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3392,12 +3906,12 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.isEuRegion - Set as EU region. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3406,12 +3920,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Mailgun provider. @@ -3420,12 +3934,12 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean | null} isEuRegion - Set as EU region. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3435,12 +3949,12 @@ export class Messaging { name: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, + isEuRegion?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMailgunProvider( paramsOrFirst: @@ -3449,24 +3963,24 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, string?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -3474,12 +3988,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3492,12 +4006,12 @@ export class Messaging { name: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; + isEuRegion?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3505,12 +4019,12 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, + isEuRegion: rest[3] as boolean | null, fromName: rest[4] as string, 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 | null, }; } @@ -3572,7 +4086,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3582,8 +4115,8 @@ export class Messaging { * @param {string} params.name - Provider name. * @param {string} params.apiKey - Mailgun API Key. * @param {string} params.domain - Mailgun Domain. - * @param {boolean} params.isEuRegion - Set as EU region. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.isEuRegion - Set as EU region. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3596,8 +4129,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3610,8 +4143,8 @@ export class Messaging { * @param {string} name - Provider name. * @param {string} apiKey - Mailgun API Key. * @param {string} domain - Mailgun Domain. - * @param {boolean} isEuRegion - Set as EU region. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} isEuRegion - Set as EU region. + * @param {boolean | null} enabled - Set as enabled. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -3625,8 +4158,8 @@ export class Messaging { name?: string, apiKey?: string, domain?: string, - isEuRegion?: boolean, - enabled?: boolean, + isEuRegion?: boolean | null, + enabled?: boolean | null, fromName?: string, fromEmail?: string, replyToName?: string, @@ -3639,8 +4172,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3651,8 +4184,8 @@ export class Messaging { string?, string?, string?, - boolean?, - boolean?, + (boolean | null)?, + (boolean | null)?, string?, string?, string?, @@ -3664,8 +4197,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3682,8 +4215,8 @@ export class Messaging { name?: string; apiKey?: string; domain?: string; - isEuRegion?: boolean; - enabled?: boolean; + isEuRegion?: boolean | null; + enabled?: boolean | null; fromName?: string; fromEmail?: string; replyToName?: string; @@ -3695,8 +4228,8 @@ export class Messaging { name: rest[0] as string, apiKey: rest[1] as string, domain: rest[2] as string, - isEuRegion: rest[3] as boolean, - enabled: rest[4] as boolean, + isEuRegion: rest[3] as boolean | null, + enabled: rest[4] as boolean | null, fromName: rest[5] as string, fromEmail: rest[6] as string, replyToName: rest[7] as string, @@ -3759,7 +4292,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3770,7 +4322,7 @@ export class Messaging { * @param {string} params.templateId - Msg91 template ID * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -3780,7 +4332,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new MSG91 provider. @@ -3790,7 +4342,7 @@ export class Messaging { * @param {string} templateId - Msg91 template ID * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3801,7 +4353,7 @@ export class Messaging { templateId?: string, senderId?: string, authKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createMsg91Provider( paramsOrFirst: @@ -3811,10 +4363,10 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -3822,7 +4374,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -3836,7 +4388,7 @@ export class Messaging { templateId?: string; senderId?: string; authKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -3845,7 +4397,7 @@ 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 | null, }; } @@ -3891,7 +4443,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3899,7 +4470,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.templateId - Msg91 template ID. * @param {string} params.senderId - Msg91 sender ID. * @param {string} params.authKey - Msg91 auth key. @@ -3909,7 +4480,7 @@ export class Messaging { updateMsg91Provider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3919,7 +4490,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} templateId - Msg91 template ID. * @param {string} senderId - Msg91 sender ID. * @param {string} authKey - Msg91 auth key. @@ -3930,7 +4501,7 @@ export class Messaging { updateMsg91Provider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, templateId?: string, senderId?: string, authKey?: string, @@ -3940,18 +4511,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3965,7 +4536,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; templateId?: string; senderId?: string; authKey?: string; @@ -3974,7 +4545,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, templateId: rest[2] as string, senderId: rest[3] as string, authKey: rest[4] as string, @@ -4020,7 +4591,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4033,7 +4623,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4045,7 +4635,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Resend provider. @@ -4057,7 +4647,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4070,7 +4660,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createResendProvider( paramsOrFirst: @@ -4082,7 +4672,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4092,7 +4682,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4103,7 +4693,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4119,7 +4709,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4130,7 +4720,7 @@ 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 | null, }; } @@ -4184,7 +4774,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4192,7 +4801,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Resend API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4204,7 +4813,7 @@ export class Messaging { updateResendProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4216,7 +4825,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Resend API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4229,7 +4838,7 @@ export class Messaging { updateResendProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4241,7 +4850,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4251,7 +4860,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4262,7 +4871,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4278,7 +4887,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4289,7 +4898,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4345,7 +4954,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4358,7 +4986,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4370,7 +4998,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Sendgrid provider. @@ -4382,7 +5010,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4395,7 +5023,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSendgridProvider( paramsOrFirst: @@ -4407,7 +5035,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4417,7 +5045,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4428,7 +5056,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4444,7 +5072,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4455,7 +5083,7 @@ 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 | null, }; } @@ -4509,7 +5137,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4517,7 +5164,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Sendgrid API key. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. @@ -4529,7 +5176,7 @@ export class Messaging { updateSendgridProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4541,7 +5188,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Sendgrid API key. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. @@ -4554,7 +5201,7 @@ export class Messaging { updateSendgridProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, fromName?: string, fromEmail?: string, @@ -4566,7 +5213,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4576,7 +5223,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4587,7 +5234,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4603,7 +5250,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; fromName?: string; fromEmail?: string; @@ -4614,7 +5261,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, fromName: rest[3] as string, fromEmail: rest[4] as string, @@ -4670,7 +5317,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4685,7 +5351,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -4699,7 +5365,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Amazon SES provider. @@ -4713,7 +5379,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4728,7 +5394,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSesProvider( paramsOrFirst: @@ -4742,7 +5408,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -4754,7 +5420,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -4767,7 +5433,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -4785,7 +5451,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -4798,7 +5464,7 @@ 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 | null, }; } @@ -4860,7 +5526,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4868,7 +5553,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accessKey - AWS access key ID. * @param {string} params.secretKey - AWS secret access key. * @param {string} params.region - AWS region, for example us-east-1. @@ -4882,7 +5567,7 @@ export class Messaging { updateSesProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4896,7 +5581,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accessKey - AWS access key ID. * @param {string} secretKey - AWS secret access key. * @param {string} region - AWS region, for example us-east-1. @@ -4911,7 +5596,7 @@ export class Messaging { updateSesProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accessKey?: string, secretKey?: string, region?: string, @@ -4925,7 +5610,7 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4937,7 +5622,7 @@ export class Messaging { | string, ...rest: [ string?, - boolean?, + (boolean | null)?, string?, string?, string?, @@ -4950,7 +5635,7 @@ export class Messaging { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4968,7 +5653,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accessKey?: string; secretKey?: string; region?: string; @@ -4981,7 +5666,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accessKey: rest[2] as string, secretKey: rest[3] as string, region: rest[4] as string, @@ -5047,7 +5732,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5066,7 +5770,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. @@ -5085,7 +5789,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5103,7 +5807,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5122,7 +5826,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSmtpProvider( paramsOrFirst: @@ -5140,7 +5844,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5156,7 +5860,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5173,7 +5877,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5195,7 +5899,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5212,7 +5916,7 @@ 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 | null, }; } @@ -5293,7 +5997,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5312,7 +6035,7 @@ export class Messaging { * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5330,7 +6053,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new SMTP provider. @@ -5348,7 +6071,7 @@ export class Messaging { * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5367,7 +6090,7 @@ export class Messaging { fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createSMTPProvider( paramsOrFirst: @@ -5385,7 +6108,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ @@ -5401,7 +6124,7 @@ export class Messaging { string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { @@ -5418,7 +6141,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5440,7 +6163,7 @@ export class Messaging { fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -5457,7 +6180,7 @@ 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 | null, }; } @@ -5538,7 +6261,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5547,17 +6289,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. @@ -5566,17 +6308,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5584,17 +6326,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5603,17 +6345,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSmtpProvider( paramsOrFirst: @@ -5621,50 +6363,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5676,34 +6418,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -5778,7 +6520,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5787,17 +6548,17 @@ export class Messaging { * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - SMTP port. + * @param {number | null} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -5805,17 +6566,17 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. @@ -5823,17 +6584,17 @@ export class Messaging { * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - SMTP port. + * @param {number | null} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' - * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {boolean | null} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5842,17 +6603,17 @@ export class Messaging { providerId: string, name?: string, host?: string, - port?: number, + port?: number | null, username?: string, password?: string, encryption?: SmtpEncryption, - autoTLS?: boolean, + autoTLS?: boolean | null, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; updateSMTPProvider( paramsOrFirst: @@ -5860,50 +6621,50 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, ...rest: [ string?, string?, - number?, + (number | null)?, string?, string?, SmtpEncryption?, - boolean?, + (boolean | null)?, string?, string?, string?, string?, string?, - boolean?, + (boolean | null)?, ] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -5915,34 +6676,34 @@ export class Messaging { providerId: string; name?: string; host?: string; - port?: number; + port?: number | null; username?: string; password?: string; encryption?: SmtpEncryption; - autoTLS?: boolean; + autoTLS?: boolean | null; mailer?: string; fromName?: string; fromEmail?: string; replyToName?: string; replyToEmail?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, host: rest[1] as string, - port: rest[2] as number, + port: rest[2] as number | null, username: rest[3] as string, password: rest[4] as string, encryption: rest[5] as SmtpEncryption, - autoTLS: rest[6] as boolean, + autoTLS: rest[6] as boolean | null, mailer: rest[7] as string, fromName: rest[8] as string, 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 | null, }; } @@ -6017,7 +6778,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6028,7 +6808,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6038,7 +6818,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Telesign provider. @@ -6048,7 +6828,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6059,7 +6839,7 @@ export class Messaging { from?: string, customerId?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTelesignProvider( paramsOrFirst: @@ -6069,10 +6849,10 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6080,7 +6860,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6094,7 +6874,7 @@ export class Messaging { from?: string; customerId?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6103,7 +6883,7 @@ 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 | null, }; } @@ -6149,7 +6929,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6157,7 +6956,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.customerId - Telesign customer ID. * @param {string} params.apiKey - Telesign API key. * @param {string} params.from - Sender number. @@ -6167,7 +6966,7 @@ export class Messaging { updateTelesignProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6177,7 +6976,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} customerId - Telesign customer ID. * @param {string} apiKey - Telesign API key. * @param {string} from - Sender number. @@ -6188,7 +6987,7 @@ export class Messaging { updateTelesignProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, customerId?: string, apiKey?: string, from?: string, @@ -6198,18 +6997,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6223,7 +7022,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; customerId?: string; apiKey?: string; from?: string; @@ -6232,7 +7031,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, customerId: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6278,7 +7077,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6289,7 +7107,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6299,7 +7117,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Textmagic provider. @@ -6309,7 +7127,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6320,7 +7138,7 @@ export class Messaging { from?: string, username?: string, apiKey?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTextmagicProvider( paramsOrFirst: @@ -6330,10 +7148,10 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6341,7 +7159,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6355,7 +7173,7 @@ export class Messaging { from?: string; username?: string; apiKey?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6364,7 +7182,7 @@ 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 | null, }; } @@ -6410,7 +7228,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6418,7 +7255,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.username - Textmagic username. * @param {string} params.apiKey - Textmagic apiKey. * @param {string} params.from - Sender number. @@ -6428,7 +7265,7 @@ export class Messaging { updateTextmagicProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6438,7 +7275,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} username - Textmagic username. * @param {string} apiKey - Textmagic apiKey. * @param {string} from - Sender number. @@ -6449,7 +7286,7 @@ export class Messaging { updateTextmagicProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, username?: string, apiKey?: string, from?: string, @@ -6459,18 +7296,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6484,7 +7321,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; username?: string; apiKey?: string; from?: string; @@ -6493,7 +7330,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, username: rest[2] as string, apiKey: rest[3] as string, from: rest[4] as string, @@ -6539,7 +7376,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6550,7 +7406,7 @@ export class Messaging { * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6560,7 +7416,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Twilio provider. @@ -6570,7 +7426,7 @@ export class Messaging { * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6581,7 +7437,7 @@ export class Messaging { from?: string, accountSid?: string, authToken?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createTwilioProvider( paramsOrFirst: @@ -6591,10 +7447,10 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6602,7 +7458,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6616,7 +7472,7 @@ export class Messaging { from?: string; accountSid?: string; authToken?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6625,7 +7481,7 @@ 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 | null, }; } @@ -6671,7 +7527,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6679,7 +7554,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.accountSid - Twilio account secret ID. * @param {string} params.authToken - Twilio authentication token. * @param {string} params.from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6689,7 +7564,7 @@ export class Messaging { updateTwilioProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6699,7 +7574,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} accountSid - Twilio account secret ID. * @param {string} authToken - Twilio authentication token. * @param {string} from - Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. @@ -6710,7 +7585,7 @@ export class Messaging { updateTwilioProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, accountSid?: string, authToken?: string, from?: string, @@ -6720,18 +7595,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6745,7 +7620,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; accountSid?: string; authToken?: string; from?: string; @@ -6754,7 +7629,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, accountSid: rest[2] as string, authToken: rest[3] as string, from: rest[4] as string, @@ -6800,7 +7675,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6811,7 +7705,7 @@ export class Messaging { * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ @@ -6821,7 +7715,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.Provider>; /** * Create a new Vonage provider. @@ -6831,7 +7725,7 @@ export class Messaging { * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6842,7 +7736,7 @@ export class Messaging { from?: string, apiKey?: string, apiSecret?: string, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.Provider>; createVonageProvider( paramsOrFirst: @@ -6852,10 +7746,10 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, string?, boolean?] + ...rest: [string?, string?, string?, string?, (boolean | null)?] ): Promise<Models.Provider> { let params: { providerId: string; @@ -6863,7 +7757,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -6877,7 +7771,7 @@ export class Messaging { from?: string; apiKey?: string; apiSecret?: string; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -6886,7 +7780,7 @@ 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 | null, }; } @@ -6932,7 +7826,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6940,7 +7853,7 @@ export class Messaging { * * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. + * @param {boolean | null} params.enabled - Set as enabled. * @param {string} params.apiKey - Vonage API key. * @param {string} params.apiSecret - Vonage API secret. * @param {string} params.from - Sender number. @@ -6950,7 +7863,7 @@ export class Messaging { updateVonageProvider(params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -6960,7 +7873,7 @@ export class Messaging { * * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. + * @param {boolean | null} enabled - Set as enabled. * @param {string} apiKey - Vonage API key. * @param {string} apiSecret - Vonage API secret. * @param {string} from - Sender number. @@ -6971,7 +7884,7 @@ export class Messaging { updateVonageProvider( providerId: string, name?: string, - enabled?: boolean, + enabled?: boolean | null, apiKey?: string, apiSecret?: string, from?: string, @@ -6981,18 +7894,18 @@ export class Messaging { | { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; } | string, - ...rest: [string?, boolean?, string?, string?, string?] + ...rest: [string?, (boolean | null)?, string?, string?, string?] ): Promise<Models.Provider> { let params: { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7006,7 +7919,7 @@ export class Messaging { params = (paramsOrFirst || {}) as { providerId: string; name?: string; - enabled?: boolean; + enabled?: boolean | null; apiKey?: string; apiSecret?: string; from?: string; @@ -7015,7 +7928,7 @@ export class Messaging { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, + enabled: rest[1] as boolean | null, apiKey: rest[2] as string, apiSecret: rest[3] as string, from: rest[4] as string, @@ -7061,7 +7974,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7118,7 +8050,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'provider', + models: { + provider: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + provider: '', + enabled: true, + type: '', + credentials: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7253,7 +8204,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topicList', + models: { + topicList: { + defaults: { + total: 0, + topics: [], + }, + properties: { + topics: { + items: 'topic', + }, + }, + }, + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7262,8 +8243,8 @@ export class Messaging { * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} params.name - Topic Name. * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ @@ -7271,8 +8252,8 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Create a new topic. @@ -7280,8 +8261,8 @@ export class Messaging { * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. * @param {string} name - Topic Name. * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7290,8 +8271,8 @@ export class Messaging { topicId: string, name: string, subscribe?: string[], - qos?: number, - expiry?: number, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; createTopic( paramsOrFirst: @@ -7299,18 +8280,18 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [string?, string[]?, (number | null)?, (number | null)?] ): Promise<Models.Topic> { let params: { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7322,16 +8303,16 @@ export class Messaging { topicId: string; name: string; subscribe?: string[]; - qos?: number; - expiry?: number; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, name: rest[0] as string, subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7373,7 +8354,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7430,7 +8430,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7438,58 +8457,63 @@ export class Messaging { * * * @param {string} params.topicId - Topic ID. - * @param {string} params.name - Topic Name. - * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} params.name - Topic Name. + * @param {string[] | null} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} params.qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} params.expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }): Promise<Models.Topic>; /** * Update a topic by its unique ID. * * * @param {string} topicId - Topic ID. - * @param {string} name - Topic Name. - * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. - * @param {number} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - * @param {number} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). + * @param {string | null} name - Topic Name. + * @param {string[] | null} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {number | null} qos - MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + * @param {number | null} expiry - Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. * @throws {AppwriteException} * @returns {Promise<Models.Topic>} * @deprecated Use the object parameter style method for a better developer experience. */ updateTopic( topicId: string, - name?: string, - subscribe?: string[], - qos?: number, - expiry?: number, + name?: string | null, + subscribe?: string[] | null, + qos?: number | null, + expiry?: number | null, ): Promise<Models.Topic>; updateTopic( paramsOrFirst: | { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; } | string, - ...rest: [string?, string[]?, number?, number?] + ...rest: [ + (string | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] ): Promise<Models.Topic> { let params: { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; if ( @@ -7499,18 +8523,18 @@ export class Messaging { ) { params = (paramsOrFirst || {}) as { topicId: string; - name?: string; - subscribe?: string[]; - qos?: number; - expiry?: number; + name?: string | null; + subscribe?: string[] | null; + qos?: number | null; + expiry?: number | null; }; } else { params = { topicId: paramsOrFirst as string, - name: rest[0] as string, - subscribe: rest[1] as string[], - qos: rest[2] as number, - expiry: rest[3] as number, + name: rest[0] as string | null, + subscribe: rest[1] as string[] | null, + qos: rest[2] as number | null, + expiry: rest[3] as number | null, }; } @@ -7549,7 +8573,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'topic', + models: { + topic: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + emailTotal: 0, + smsTotal: 0, + pushTotal: 0, + subscribe: ['users'], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7707,7 +8750,37 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriberList', + models: { + subscriberList: { + defaults: { + total: 0, + subscribers: [], + }, + properties: { + subscribers: { + items: 'subscriber', + }, + }, + }, + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7802,7 +8875,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7880,7 +8972,26 @@ export class Messaging { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'subscriber', + models: { + subscriber: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + targetId: '', + userId: '', + userName: '', + topicId: '', + providerType: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/mongo.ts b/src/services/mongo.ts index e4ce1d9..169782c 100644 --- a/src/services/mongo.ts +++ b/src/services/mongo.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mongo { @@ -58,7 +63,74 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mongo { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mongo { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mongo { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mongo { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mongo { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,40 +2620,59 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2045,12 +2681,12 @@ export class Mongo { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2077,7 +2713,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2169,7 +2861,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2177,21 +2925,21 @@ export class Mongo { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2199,18 +2947,22 @@ export class Mongo { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2221,13 +2973,13 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2263,7 +3015,63 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2367,7 +3175,37 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2424,7 +3262,20 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2481,7 +3332,36 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2597,35 +3477,78 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2633,28 +3556,45 @@ export class Mongo { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -2665,17 +3605,23 @@ export class Mongo { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -2684,6 +3630,9 @@ export class Mongo { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -2706,6 +3655,15 @@ export class Mongo { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2714,7 +3672,26 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2790,7 +3767,129 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mongo/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2845,7 +3944,52 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2923,6 +4067,62 @@ export class Mongo { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/mysql.ts b/src/services/mysql.ts index 701198f..13e7de1 100644 --- a/src/services/mysql.ts +++ b/src/services/mysql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Mysql { @@ -58,7 +63,74 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Mysql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Mysql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Mysql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Mysql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Mysql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Mysql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,40 +2747,68 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2153,12 +2817,12 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2185,7 +2849,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2277,7 +2997,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2285,21 +3061,21 @@ export class Mysql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2307,18 +3083,22 @@ export class Mysql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2329,13 +3109,13 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2371,7 +3151,63 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2475,7 +3311,37 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2532,7 +3398,20 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2589,97 +3468,118 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2689,26 +3589,26 @@ export class Mysql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2763,7 +3663,28 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2820,7 +3741,36 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2936,35 +3886,78 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2972,28 +3965,45 @@ export class Mysql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3004,17 +4014,23 @@ export class Mysql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3023,6 +4039,9 @@ export class Mysql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3045,6 +4064,15 @@ export class Mysql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3053,7 +4081,26 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3129,7 +4176,129 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/mysql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3184,7 +4353,52 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3262,6 +4476,62 @@ export class Mysql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/oauth-2.ts b/src/services/oauth-2.ts index 31f94b9..84e0c31 100644 --- a/src/services/oauth-2.ts +++ b/src/services/oauth-2.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Oauth2 { @@ -96,7 +101,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Approve', + models: { + oauth2Approve: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -113,7 +130,7 @@ export class Oauth2 { * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -131,7 +148,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -149,7 +166,7 @@ export class Oauth2 { * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -168,7 +185,7 @@ export class Oauth2 { prompt?: string, maxAge?: number, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -186,7 +203,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -202,7 +219,7 @@ export class Oauth2 { string?, number?, string?, - string?, + string[]?, string?, string?, ] @@ -219,7 +236,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -242,7 +259,7 @@ export class Oauth2 { prompt?: string; maxAge?: number; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -259,7 +276,7 @@ export class Oauth2 { prompt: rest[7] as string, maxAge: rest[8] as number, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -332,7 +349,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -347,9 +377,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} params.maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} params.requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -365,9 +395,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }): Promise<Models.Oauth2Authorize>; @@ -383,9 +413,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + * @param {number | null} maxAge - OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @param {string} requestUri - OAuth2 authorization request handle returned by the pushed authorization request endpoint. * @throws {AppwriteException} @@ -402,9 +432,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, requestUri?: string, ): Promise<Models.Oauth2Authorize>; @@ -420,9 +450,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; } @@ -436,9 +466,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, string?, ] @@ -453,9 +483,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -476,9 +506,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; requestUri?: string; }; @@ -493,9 +523,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, requestUri: rest[12] as string, }; @@ -569,7 +599,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Authorize', + models: { + oauth2Authorize: { + defaults: { + grantId: '', + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -578,7 +621,7 @@ export class Oauth2 { * @param {string} params.clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} params.scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -587,7 +630,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2DeviceAuthorization>; /** @@ -596,7 +639,7 @@ export class Oauth2 { * @param {string} clientId - OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. * @param {string} scope - Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2DeviceAuthorization>} @@ -606,7 +649,7 @@ export class Oauth2 { clientId?: string, scope?: string, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2DeviceAuthorization>; createDeviceAuthorization( @@ -615,17 +658,17 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [string?, string?, string[]?, string?] ): Promise<Models.Oauth2DeviceAuthorization> { let params: { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -639,7 +682,7 @@ export class Oauth2 { clientId?: string; scope?: string; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -647,7 +690,7 @@ export class Oauth2 { clientId: paramsOrFirst as string, scope: rest[0] as string, authorizationDetails: rest[1] as string, - resource: rest[2] as string, + resource: rest[2] as string[], audience: rest[3] as string, }; } @@ -684,7 +727,24 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2DeviceAuthorization', + models: { + oauth2DeviceAuthorization: { + defaults: { + device_code: '', + user_code: '', + verification_uri: '', + verification_uri_complete: '', + expires_in: 0, + interval: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -742,7 +802,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -798,7 +881,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Grant', + models: { + oauth2Grant: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + appId: '', + scopes: [], + resources: [], + authorizationDetails: '[]', + prompt: '', + redirectUri: '', + authTime: 0, + expire: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -903,7 +1009,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Introspection', + models: { + oauth2Introspection: { + defaults: { + active: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -984,7 +1102,30 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2OrganizationList', + models: { + oauth2OrganizationList: { + defaults: { + total: 0, + organizations: [], + }, + properties: { + organizations: { + items: 'oauth2Organization', + }, + }, + }, + oauth2Organization: { + defaults: { + $id: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -999,9 +1140,9 @@ export class Oauth2 { * @param {string} params.codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} params.codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} params.prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} params.maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} params.maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} params.authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1016,9 +1157,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2PAR>; /** @@ -1033,9 +1174,9 @@ export class Oauth2 { * @param {string} codeChallenge - PKCE code challenge. Required when OAuth2 app is public. * @param {string} codeChallengeMethod - PKCE code challenge method. Required when OAuth2 app is public. * @param {string} prompt - OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. - * @param {number} maxAge - OIDC max_age parameter for customization of consent screen. + * @param {number | null} maxAge - OIDC max_age parameter for customization of consent screen. * @param {string} authorizationDetails - Rich authorization request. JSON array of objects, each with a `type` and project-defined fields - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2PAR>} @@ -1051,9 +1192,9 @@ export class Oauth2 { codeChallenge?: string, codeChallengeMethod?: string, prompt?: string, - maxAge?: number, + maxAge?: number | null, authorizationDetails?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2PAR>; createPAR( @@ -1068,9 +1209,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1083,9 +1224,9 @@ export class Oauth2 { string?, string?, string?, - number?, - string?, + (number | null)?, string?, + string[]?, string?, ] ): Promise<Models.Oauth2PAR> { @@ -1099,9 +1240,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1120,9 +1261,9 @@ export class Oauth2 { codeChallenge?: string; codeChallengeMethod?: string; prompt?: string; - maxAge?: number; + maxAge?: number | null; authorizationDetails?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1136,9 +1277,9 @@ export class Oauth2 { codeChallenge: rest[5] as string, codeChallengeMethod: rest[6] as string, prompt: rest[7] as string, - maxAge: rest[8] as number, + maxAge: rest[8] as number | null, authorizationDetails: rest[9] as string, - resource: rest[10] as string, + resource: rest[10] as string[], audience: rest[11] as string, }; } @@ -1222,7 +1363,20 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2PAR', + models: { + oauth2PAR: { + defaults: { + request_uri: '', + expires_in: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1303,7 +1457,32 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2ProjectList', + models: { + oauth2ProjectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'oauth2Project', + }, + }, + }, + oauth2Project: { + defaults: { + $id: '', + region: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1361,7 +1540,19 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Reject', + models: { + oauth2Reject: { + defaults: { + redirectUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1671,7 @@ export class Oauth2 { * @param {string} params.clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} params.codeVerifier - PKCE code verifier. Required for public apps. * @param {string} params.redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} params.resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} params.audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1494,7 +1685,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }): Promise<Models.Oauth2Token>; /** @@ -1508,7 +1699,7 @@ export class Oauth2 { * @param {string} clientSecret - OAuth2 client secret. Required for confidential apps. * @param {string} codeVerifier - PKCE code verifier. Required for public apps. * @param {string} redirectUri - Redirect URI. Required for `authorization_code` grant type. - * @param {string} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + * @param {string[]} resource - RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. * @param {string} audience - Compatibility alias for a single OAuth2 resource indicator URI. * @throws {AppwriteException} * @returns {Promise<Models.Oauth2Token>} @@ -1523,7 +1714,7 @@ export class Oauth2 { clientSecret?: string, codeVerifier?: string, redirectUri?: string, - resource?: string, + resource?: string[], audience?: string, ): Promise<Models.Oauth2Token>; createToken( @@ -1537,7 +1728,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; } | string, @@ -1549,7 +1740,7 @@ export class Oauth2 { string?, string?, string?, - string?, + string[]?, string?, ] ): Promise<Models.Oauth2Token> { @@ -1562,7 +1753,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; @@ -1580,7 +1771,7 @@ export class Oauth2 { clientSecret?: string; codeVerifier?: string; redirectUri?: string; - resource?: string; + resource?: string[]; audience?: string; }; } else { @@ -1593,7 +1784,7 @@ export class Oauth2 { clientSecret: rest[4] as string, codeVerifier: rest[5] as string, redirectUri: rest[6] as string, - resource: rest[7] as string, + resource: rest[7] as string[], audience: rest[8] as string, }; } @@ -1655,6 +1846,22 @@ export class Oauth2 { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oauth2Token', + models: { + oauth2Token: { + defaults: { + access_token: '', + token_type: 'Bearer', + expires_in: 0, + refresh_token: '', + scope: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/organization.ts b/src/services/organization.ts index 955a696..37dffa7 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { Region } from '../enums/region'; @@ -28,7 +33,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -86,7 +115,31 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'organization', + models: { + organization: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + budgetAlerts: [75], + billingPlan: 'tier-0', + billingPlanId: 'tier-0', + billingEmail: '', + status: 'draft', + markedForDeletion: false, + platform: 'appwrite', + projects: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -174,7 +227,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,7 +330,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -303,40 +407,64 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. */ updateInstallation( installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: - { installationId: string; authorizationDetails?: string } | string, - ...rest: [string?] + | { installationId: string; authorizationDetails?: string | null } + | string, + ...rest: [(string | null)?] ): Promise<Models.AppInstallation> { - let params: { installationId: string; authorizationDetails?: string }; + let params: { + installationId: string; + authorizationDetails?: string | null; + }; if ( paramsOrFirst && @@ -345,12 +473,12 @@ export class Organization { ) { params = (paramsOrFirst || {}) as { installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { installationId: paramsOrFirst as string, - authorizationDetails: rest[0] as string, + authorizationDetails: rest[0] as string | null, }; } @@ -377,7 +505,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -512,7 +660,44 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -639,7 +824,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +905,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -770,7 +1007,33 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -905,7 +1168,92 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -992,7 +1340,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1047,7 +1469,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1120,7 +1616,81 @@ export class Organization { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1257,7 +1827,38 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1363,7 +1964,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +2052,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1441,7 +2082,7 @@ export class Organization { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -1450,7 +2091,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -1459,7 +2100,7 @@ export class Organization { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1469,7 +2110,7 @@ export class Organization { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateProjectKey( paramsOrFirst: @@ -1478,17 +2119,17 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { projectId: string; keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -1501,7 +2142,7 @@ export class Organization { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } else { params = { @@ -1509,7 +2150,7 @@ export class Organization { keyId: rest[0] as string, name: rest[1] as string, scopes: rest[2] as ProjectKeyScopes[], - expire: rest[3] as string, + expire: rest[3] as string | null, }; } @@ -1553,7 +2194,27 @@ export class Organization { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/postgresql.ts b/src/services/postgresql.ts index ec5659b..aafaf2d 100644 --- a/src/services/postgresql.ts +++ b/src/services/postgresql.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Postgresql { @@ -58,7 +63,74 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseList', + models: { + dedicatedDatabaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'dedicatedDatabase', + }, + }, + }, + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -66,54 +138,54 @@ export class Postgresql { * * @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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ create(params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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 | null} 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 {string | null} 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 {string[] | null} 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. Defaults to 3 times the specification's storage. 0 means no limit. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -121,69 +193,69 @@ export class Postgresql { create( databaseId: string, name: string, - version?: string, + version?: string | null, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, networkIdleTimeoutSeconds?: number, - networkIPAllowlist?: string[], + networkIPAllowlist?: string[] | null, idleTimeoutMinutes?: number, pitr?: boolean, pitrRetentionDays?: number, storageAutoscaling?: boolean, storageAutoscalingThresholdPercent?: number, - storageAutoscalingMaxGb?: number, + storageAutoscalingMaxGb?: number | null, ): Promise<Models.DedicatedDatabase>; create( paramsOrFirst: | { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; } | string, ...rest: [ string?, - string?, + (string | null)?, string?, number?, - string?, + (string | null)?, number?, - string[]?, + (string[] | null)?, number?, boolean?, number?, boolean?, number?, - number?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; if ( @@ -194,35 +266,35 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; name: string; - version?: string; + version?: string | null; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; networkIdleTimeoutSeconds?: number; - networkIPAllowlist?: string[]; + networkIPAllowlist?: string[] | null; idleTimeoutMinutes?: number; pitr?: boolean; pitrRetentionDays?: number; storageAutoscaling?: boolean; storageAutoscalingThresholdPercent?: number; - storageAutoscalingMaxGb?: number; + storageAutoscalingMaxGb?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, name: rest[0] as string, - version: rest[1] as string, + version: rest[1] as string | null, specification: rest[2] as string, replicas: rest[3] as number, - syncMode: rest[4] as string, + syncMode: rest[4] as string | null, networkIdleTimeoutSeconds: rest[5] as number, - networkIPAllowlist: rest[6] as string[], + networkIPAllowlist: rest[6] as string[] | null, 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, + storageAutoscalingMaxGb: rest[12] as number | null, }; } @@ -302,7 +374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -321,7 +449,42 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -376,181 +539,237 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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). + * @param {string | null} params.name - Database display name. + * @param {string | null} 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 | null} 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 | null} params.replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} params.syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} params.networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} params.networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} params.idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} params.pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} params.pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} params.storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} params.storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} params.storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} params.metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} params.metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} params.sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} params.sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} params.sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} params.sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} params.sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabase>; /** * 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). + * @param {string | null} name - Database display name. + * @param {string | null} 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 | null} 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 | null} replicas - Number of high availability replicas (0-5). High availability is enabled when greater than 0. + * @param {string | null} syncMode - Replication sync mode preference. Allowed values: async, sync, quorum. + * @param {number | null} networkIdleTimeoutSeconds - Connection idle timeout in seconds (60-86400). + * @param {string[] | null} networkIPAllowlist - IP addresses/CIDR ranges allowed to connect. + * @param {number | null} idleTimeoutMinutes - Minutes before container scales to zero. + * @param {boolean | null} pitr - Enable or disable point-in-time recovery (PITR). + * @param {number | null} pitrRetentionDays - Days to retain PITR data. + * @param {boolean | null} storageAutoscaling - Enable automatic storage expansion when usage exceeds threshold. + * @param {number | null} storageAutoscalingThresholdPercent - Storage usage percentage (50-95) that triggers automatic expansion. + * @param {number | null} storageAutoscalingMaxGb - Maximum storage size in GB for autoscaling. 0 means no limit. + * @param {number | null} metricsTraceSampleRate - Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar. + * @param {number | null} metricsSlowQueryLogThresholdMs - Threshold in ms above which queries are logged as slow. Forwarded to the sidecar. + * @param {boolean | null} sqlApiEnabled - Enable the SQL API sidecar for this database. + * @param {string[] | null} sqlApiAllowedStatements - Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE. + * @param {number | null} sqlApiMaxRows - Maximum rows returned per SQL API execution (1-1000000). + * @param {number | null} sqlApiMaxBytes - Maximum serialised SQL API result payload in bytes (1024-104857600). + * @param {number | null} sqlApiTimeoutSeconds - Per-call SQL API execution timeout in seconds (1-300). * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @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, + name?: string | null, + status?: string | null, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, + networkIdleTimeoutSeconds?: number | null, + networkIPAllowlist?: string[] | null, + idleTimeoutMinutes?: number | null, + pitr?: boolean | null, + pitrRetentionDays?: number | null, + storageAutoscaling?: boolean | null, + storageAutoscalingThresholdPercent?: number | null, + storageAutoscalingMaxGb?: number | null, + metricsTraceSampleRate?: number | null, + metricsSlowQueryLogThresholdMs?: number | null, + sqlApiEnabled?: boolean | null, + sqlApiAllowedStatements?: string[] | null, + sqlApiMaxRows?: number | null, + sqlApiMaxBytes?: number | null, + sqlApiTimeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabase>; 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; } | string, ...rest: [ - string?, - string?, - string?, - number?, - string?, - number?, - string[]?, - number?, - boolean?, - number?, - boolean?, - number?, - number?, - number?, - number?, - boolean?, - string[]?, - number?, - number?, - number?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (string[] | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (boolean | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + (number | null)?, ] ): Promise<Models.DedicatedDatabase> { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; if ( @@ -560,50 +779,50 @@ export class Postgresql { ) { 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; + name?: string | null; + status?: string | null; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; + networkIdleTimeoutSeconds?: number | null; + networkIPAllowlist?: string[] | null; + idleTimeoutMinutes?: number | null; + pitr?: boolean | null; + pitrRetentionDays?: number | null; + storageAutoscaling?: boolean | null; + storageAutoscalingThresholdPercent?: number | null; + storageAutoscalingMaxGb?: number | null; + metricsTraceSampleRate?: number | null; + metricsSlowQueryLogThresholdMs?: number | null; + sqlApiEnabled?: boolean | null; + sqlApiAllowedStatements?: string[] | null; + sqlApiMaxRows?: number | null; + sqlApiMaxBytes?: number | null; + sqlApiTimeoutSeconds?: number | null; }; } 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, + name: rest[0] as string | null, + status: rest[1] as string | null, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, + networkIdleTimeoutSeconds: rest[5] as number | null, + networkIPAllowlist: rest[6] as string[] | null, + idleTimeoutMinutes: rest[7] as number | null, + pitr: rest[8] as boolean | null, + pitrRetentionDays: rest[9] as number | null, + storageAutoscaling: rest[10] as boolean | null, + storageAutoscalingThresholdPercent: rest[11] as number | null, + storageAutoscalingMaxGb: rest[12] as number | null, + metricsTraceSampleRate: rest[13] as number | null, + metricsSlowQueryLogThresholdMs: rest[14] as number | null, + sqlApiEnabled: rest[15] as boolean | null, + sqlApiAllowedStatements: rest[16] as string[] | null, + sqlApiMaxRows: rest[17] as number | null, + sqlApiMaxBytes: rest[18] as number | null, + sqlApiTimeoutSeconds: rest[19] as number | null, }; } @@ -710,7 +929,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -836,7 +1111,41 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupList', + models: { + dedicatedDatabaseBackupList: { + defaults: { + total: 0, + backups: [], + }, + properties: { + backups: { + items: 'dedicatedDatabaseBackup', + }, + }, + }, + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -909,7 +1218,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -981,7 +1313,39 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicyList', + models: { + backupPolicyList: { + defaults: { + total: 0, + policies: [], + }, + properties: { + policies: { + items: 'backupPolicy', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1140,7 +1504,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1213,7 +1598,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1221,30 +1627,30 @@ export class Postgresql { * * @param {string} params.databaseId - Database ID. * @param {string} params.policyId - Policy ID. - * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string | null} 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. + * @param {number | null} params.retention - Days to keep backups before deletion. + * @param {boolean | null} params.enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} */ updateBackupPolicy(params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }): Promise<Models.BackupPolicy>; /** * 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 | null} 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. + * @param {number | null} retention - Days to keep backups before deletion. + * @param {boolean | null} enabled - Is policy enabled? When disabled, no backups will be taken. * @throws {AppwriteException} * @returns {Promise<Models.BackupPolicy>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1252,31 +1658,37 @@ export class Postgresql { updateBackupPolicy( databaseId: string, policyId: string, - name?: string, + name?: string | null, schedule?: string, - retention?: number, - enabled?: boolean, + retention?: number | null, + enabled?: boolean | null, ): Promise<Models.BackupPolicy>; updateBackupPolicy( paramsOrFirst: | { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, string?, number?, boolean?] + ...rest: [ + string?, + (string | null)?, + string?, + (number | null)?, + (boolean | null)?, + ] ): Promise<Models.BackupPolicy> { let params: { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; if ( @@ -1287,19 +1699,19 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; policyId: string; - name?: string; + name?: string | null; schedule?: string; - retention?: number; - enabled?: boolean; + retention?: number | null; + enabled?: boolean | null; }; } else { params = { databaseId: paramsOrFirst as string, policyId: rest[0] as string, - name: rest[1] as string, + name: rest[1] as string | null, schedule: rest[2] as string, - retention: rest[3] as number, - enabled: rest[4] as boolean, + retention: rest[3] as number | null, + enabled: rest[4] as boolean | null, }; } @@ -1343,7 +1755,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'backupPolicy', + models: { + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1585,7 +2018,23 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackupStorage', + models: { + dedicatedDatabaseBackupStorage: { + defaults: { + provider: '', + bucket: '', + region: '', + prefix: 'backups/', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1658,7 +2107,30 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBackup', + models: { + dedicatedDatabaseBackup: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + policyId: '', + trigger: 'manual', + type: 'full', + requestedType: '', + fallbackReason: '', + status: 'pending', + sizeBytes: 0, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1785,7 +2257,40 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseBranchList', + models: { + dedicatedDatabaseBranchList: { + defaults: { + total: 0, + branches: [], + }, + properties: { + branches: { + items: 'dedicatedDatabaseBranch', + }, + }, + }, + dedicatedDatabaseBranch: { + defaults: { + branchId: '', + branchName: '', + namespace: '', + expiresAt: 0, + host: '', + database: '', + username: '', + password: '', + ssl: false, + engine: '', + connectionString: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1869,7 +2374,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1943,7 +2504,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2003,32 +2620,51 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperation', + models: { + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} 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 | null} params.timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} */ createExecution(params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }): Promise<Models.DedicatedDatabaseExecution>; /** - * 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. + * 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. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. * * @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. + * @param {object | null} bindings - Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. + * @param {number | null} timeoutSeconds - Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseExecution>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2036,25 +2672,25 @@ export class Postgresql { createExecution( databaseId: string, sql: string, - bindings?: object, - timeoutSeconds?: number, + bindings?: object | null, + timeoutSeconds?: number | null, ): Promise<Models.DedicatedDatabaseExecution>; createExecution( paramsOrFirst: | { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; } | string, - ...rest: [string?, object?, number?] + ...rest: [string?, (object | null)?, (number | null)?] ): Promise<Models.DedicatedDatabaseExecution> { let params: { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; if ( @@ -2065,15 +2701,15 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; sql: string; - bindings?: object; - timeoutSeconds?: number; + bindings?: object | null; + timeoutSeconds?: number | null; }; } else { params = { databaseId: paramsOrFirst as string, sql: rest[0] as string, - bindings: rest[1] as object, - timeoutSeconds: rest[2] as number, + bindings: rest[1] as object | null, + timeoutSeconds: rest[2] as number | null, }; } @@ -2111,7 +2747,35 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExecution', + models: { + dedicatedDatabaseExecution: { + defaults: { + rows: [], + rowCount: 0, + columns: [], + durationMs: 0, + truncated: false, + bytes: 0, + }, + properties: { + columns: { + items: 'dedicatedDatabaseExecutionColumn', + }, + }, + }, + dedicatedDatabaseExecutionColumn: { + defaults: { + name: '', + type: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2170,7 +2834,34 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseExtensions', + models: { + dedicatedDatabaseExtensions: { + defaults: { + installed: [], + available: [], + metadata: [], + }, + properties: { + metadata: { + items: 'postgresExtension', + }, + }, + }, + postgresExtension: { + defaults: { + key: '', + name: '', + description: '', + category: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2246,7 +2937,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2323,40 +3070,96 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -2365,12 +3168,12 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -2397,7 +3200,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2489,7 +3348,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2497,21 +3412,21 @@ export class Postgresql { * * @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. + * @param {string | null} params.specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createMigration(params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} specification - Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2519,18 +3434,22 @@ export class Postgresql { createMigration( databaseId: string, targetType: string, - specification?: string, + specification?: string | null, ): Promise<Models.DedicatedDatabase>; createMigration( paramsOrFirst: - | { databaseId: string; targetType: string; specification?: string } + | { + databaseId: string; + targetType: string; + specification?: string | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.DedicatedDatabase> { let params: { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; if ( @@ -2541,13 +3460,13 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; targetType: string; - specification?: string; + specification?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, targetType: rest[0] as string, - specification: rest[1] as string, + specification: rest[1] as string | null, }; } @@ -2583,7 +3502,63 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2687,7 +3662,37 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2744,7 +3749,20 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePITRWindows', + models: { + dedicatedDatabasePITRWindows: { + defaults: { + earliest: '', + latest: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2801,97 +3819,118 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} 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 | null} 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 | null} params.defaultPoolSize - Default pool size per user. + * @param {boolean | null} params.readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} */ updatePooler(params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }): Promise<Models.DedicatedDatabasePooler>; /** * 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. + * @param {string | null} 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 | null} 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 | null} defaultPoolSize - Default pool size per user. + * @param {boolean | null} readWriteSplitting - Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. + * @param {string | null} 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 | null} 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 | null} 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 | null} 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<Models.DedicatedDatabasePooler>} * @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, + mode?: string | null, + maxConnections?: number | null, + defaultPoolSize?: number | null, + readWriteSplitting?: boolean | null, + poolerCpuRequest?: string | null, + poolerCpuLimit?: string | null, + poolerMemoryRequest?: string | null, + poolerMemoryLimit?: string | null, ): Promise<Models.DedicatedDatabasePooler>; updatePooler( paramsOrFirst: | { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; } | string, ...rest: [ - string?, - number?, - number?, - boolean?, - string?, - string?, - string?, - string?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.DedicatedDatabasePooler> { let params: { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; if ( @@ -2901,26 +3940,26 @@ export class Postgresql { ) { params = (paramsOrFirst || {}) as { databaseId: string; - mode?: string; - maxConnections?: number; - defaultPoolSize?: number; - readWriteSplitting?: boolean; - poolerCpuRequest?: string; - poolerCpuLimit?: string; - poolerMemoryRequest?: string; - poolerMemoryLimit?: string; + mode?: string | null; + maxConnections?: number | null; + defaultPoolSize?: number | null; + readWriteSplitting?: boolean | null; + poolerCpuRequest?: string | null; + poolerCpuLimit?: string | null; + poolerMemoryRequest?: string | null; + poolerMemoryLimit?: string | null; }; } 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, + mode: rest[0] as string | null, + maxConnections: rest[1] as number | null, + defaultPoolSize: rest[2] as number | null, + readWriteSplitting: rest[3] as boolean | null, + poolerCpuRequest: rest[4] as string | null, + poolerCpuLimit: rest[5] as string | null, + poolerMemoryRequest: rest[6] as string | null, + poolerMemoryLimit: rest[7] as string | null, }; } @@ -2975,7 +4014,28 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabasePooler', + models: { + dedicatedDatabasePooler: { + defaults: { + enabled: false, + mode: 'transaction', + maxConnections: 100, + defaultPoolSize: 20, + port: 6432, + readWriteSplitting: false, + poolerCpuRequest: '', + poolerCpuLimit: '', + poolerMemoryRequest: '', + poolerMemoryLimit: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3032,7 +4092,36 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3148,35 +4237,78 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestorationList', + models: { + dedicatedDatabaseRestorationList: { + defaults: { + total: 0, + restorations: [], + }, + properties: { + restorations: { + items: 'dedicatedDatabaseRestoration', + }, + }, + }, + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} params.backupId - Backup ID to restore from (required for backup type). + * @param {string | null} params.targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} params.restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} params.targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} params.autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} */ createRestoration(params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }): Promise<Models.DedicatedDatabaseRestoration>; /** * 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. * + * By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. + * * @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. + * @param {string | null} backupId - Backup ID to restore from (required for backup type). + * @param {string | null} targetDatabaseId - Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. + * @param {string | null} 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. + * @param {string | null} restoreMode - Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + * @param {string | null} targetName - Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + * @param {boolean} autoPromote - Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabaseRestoration>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3184,28 +4316,45 @@ export class Postgresql { createRestoration( databaseId: string, type?: string, - backupId?: string, - targetDatabaseId?: string, - targetTime?: string, + backupId?: string | null, + targetDatabaseId?: string | null, + targetTime?: string | null, + restoreMode?: string | null, + targetName?: string | null, + autoPromote?: boolean, ): Promise<Models.DedicatedDatabaseRestoration>; createRestoration( paramsOrFirst: | { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + boolean?, + ] ): Promise<Models.DedicatedDatabaseRestoration> { let params: { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; if ( @@ -3216,17 +4365,23 @@ export class Postgresql { params = (paramsOrFirst || {}) as { databaseId: string; type?: string; - backupId?: string; - targetDatabaseId?: string; - targetTime?: string; + backupId?: string | null; + targetDatabaseId?: string | null; + targetTime?: string | null; + restoreMode?: string | null; + targetName?: string | null; + autoPromote?: boolean; }; } 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, + backupId: rest[1] as string | null, + targetDatabaseId: rest[2] as string | null, + targetTime: rest[3] as string | null, + restoreMode: rest[4] as string | null, + targetName: rest[5] as string | null, + autoPromote: rest[6] as boolean, }; } @@ -3235,6 +4390,9 @@ export class Postgresql { const backupId = params.backupId; const targetDatabaseId = params.targetDatabaseId; const targetTime = params.targetTime; + const restoreMode = params.restoreMode; + const targetName = params.targetName; + const autoPromote = params.autoPromote; if (typeof databaseId === 'undefined' || databaseId === '') { throw new AppwriteException( 'Missing required parameter: "databaseId"', @@ -3257,6 +4415,15 @@ export class Postgresql { if (typeof targetTime !== 'undefined') { apiPayload['targetTime'] = targetTime; } + if (typeof restoreMode !== 'undefined') { + apiPayload['restoreMode'] = restoreMode; + } + if (typeof targetName !== 'undefined') { + apiPayload['targetName'] = targetName; + } + if (typeof autoPromote !== 'undefined') { + apiPayload['autoPromote'] = autoPromote; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3265,7 +4432,26 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3341,7 +4527,129 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + */ + promoteRestoration(params: { + databaseId: string; + restorationId: string; + }): Promise<Models.DedicatedDatabaseRestoration>; + /** + * Switch the database over to the clone a restoration recovered. The database keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained briefly so + * the switch can be reversed. + * + * @param {string} databaseId - Database ID. + * @param {string} restorationId - Restoration ID. + * @throws {AppwriteException} + * @returns {Promise<Models.DedicatedDatabaseRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + promoteRestoration( + databaseId: string, + restorationId: string, + ): Promise<Models.DedicatedDatabaseRestoration>; + promoteRestoration( + paramsOrFirst: { databaseId: string; restorationId: string } | string, + ...rest: [string?] + ): Promise<Models.DedicatedDatabaseRestoration> { + 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' || databaseId === '') { + throw new AppwriteException( + 'Missing required parameter: "databaseId"', + ); + } + if (typeof restorationId === 'undefined' || restorationId === '') { + throw new AppwriteException( + 'Missing required parameter: "restorationId"', + ); + } + const apiPath = + '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + .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, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseRestoration', + models: { + dedicatedDatabaseRestoration: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + projectId: '', + type: 'backup', + restoreMode: 'in_place', + status: 'pending', + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3396,7 +4704,52 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3474,6 +4827,62 @@ export class Postgresql { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/presences.ts b/src/services/presences.ts index eced57c..edc7fe1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Presences { @@ -86,7 +91,35 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presenceList', + models: { + presenceList: { + defaults: { + total: 0, + presences: [], + }, + properties: { + presences: { + items: 'presence', + }, + }, + }, + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -143,7 +176,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -280,7 +330,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -426,7 +493,24 @@ export class Presences { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'presence', + models: { + presence: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + userId: '', + source: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/project.ts b/src/services/project.ts index 7d59be7..6e554ab 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; @@ -43,7 +48,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -69,7 +148,7 @@ export class 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 {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} params.enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -81,7 +160,7 @@ export class 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 {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey * @param {boolean} enabled - Auth method status. * @throws {AppwriteException} * @returns {Promise<Models.Project>} @@ -144,7 +223,719 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + */ + listEnvironments(params?: { + queries?: string[]; + total?: boolean; + }): Promise<Models.ProjectList>; + /** + * Get a list of all environments of the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt, status, parentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProjectList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEnvironments( + queries?: string[], + total?: boolean, + ): Promise<Models.ProjectList>; + listEnvironments( + paramsOrFirst?: { queries?: string[]; total?: boolean } | string[], + ...rest: [boolean?] + ): Promise<Models.ProjectList> { + let params: { queries?: string[]; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + }; + } + + const queries = params.queries; + const total = params.total; + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'projectList', + models: { + projectList: { + defaults: { + total: 0, + projects: [], + }, + properties: { + projects: { + items: 'project', + }, + }, + }, + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} params.environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + createEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. + * + * @param {string} environmentId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + createEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments'; + const apiPayload: Payload = {}; + if (typeof environmentId !== 'undefined') { + apiPayload['environmentId'] = environmentId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get an environment of the project by its unique ID. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + getEnvironment(params: { environmentId: string }): Promise<Models.Project>; + /** + * Get an environment of the project by its unique ID. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEnvironment(environmentId: string): Promise<Models.Project>; + getEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<Models.Project> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update the name of an environment of the project. + * + * @param {string} params.environmentId - Environment unique ID. + * @param {string} params.name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateEnvironment(params: { + environmentId: string; + name: string; + }): Promise<Models.Project>; + /** + * Update the name of an environment of the project. + * + * @param {string} environmentId - Environment unique ID. + * @param {string} name - Environment name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnvironment( + environmentId: string, + name: string, + ): Promise<Models.Project>; + updateEnvironment( + paramsOrFirst: { environmentId: string; name: string } | string, + ...rest: [string?] + ): Promise<Models.Project> { + let params: { environmentId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + environmentId: string; + name: string; + }; + } else { + params = { + environmentId: paramsOrFirst as string, + name: rest[0] as string, + }; + } + + const environmentId = params.environmentId; + const name = params.name; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} params.environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteEnvironment(params: { environmentId: string }): Promise<{}>; + /** + * Delete an environment of the project, with all of its resources and users. + * + * @param {string} environmentId - Environment unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteEnvironment(environmentId: string): Promise<{}>; + deleteEnvironment( + paramsOrFirst: { environmentId: string } | string, + ): Promise<{}> { + let params: { environmentId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { environmentId: string }; + } else { + params = { + environmentId: paramsOrFirst as string, + }; + } + + const environmentId = params.environmentId; + if (typeof environmentId === 'undefined' || environmentId === '') { + throw new AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + const apiPath = '/project/environments/{environmentId}'.replace( + '{environmentId}', + encodeURIComponent(String(environmentId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); } /** @@ -209,7 +1000,38 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'keyList', + models: { + keyList: { + defaults: { + total: 0, + keys: [], + }, + properties: { + keys: { + items: 'key', + }, + }, + }, + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -292,7 +1114,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'ephemeralKey', + models: { + ephemeralKey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -343,7 +1185,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -352,7 +1214,7 @@ export class Project { * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} */ @@ -360,7 +1222,7 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }): Promise<Models.Key>; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. @@ -368,7 +1230,7 @@ export class Project { * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 200 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @param {string | null} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise<Models.Key>} * @deprecated Use the object parameter style method for a better developer experience. @@ -377,7 +1239,7 @@ export class Project { keyId: string, name: string, scopes: ProjectKeyScopes[], - expire?: string, + expire?: string | null, ): Promise<Models.Key>; updateKey( paramsOrFirst: @@ -385,16 +1247,16 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; } | string, - ...rest: [string?, ProjectKeyScopes[]?, string?] + ...rest: [string?, ProjectKeyScopes[]?, (string | null)?] ): Promise<Models.Key> { let params: { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; if ( @@ -406,14 +1268,14 @@ export class Project { keyId: string; name: string; scopes: ProjectKeyScopes[]; - expire?: string; + expire?: string | null; }; } 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 | null, }; } @@ -452,7 +1314,27 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'key', + models: { + key: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + expire: '', + scopes: [], + secret: '', + accessedAt: '', + sdks: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -558,7 +1440,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -626,7 +1582,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumberList', + models: { + mockNumberList: { + defaults: { + total: 0, + mockNumbers: [], + }, + properties: { + mockNumbers: { + items: 'mockNumber', + }, + }, + }, + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -694,7 +1676,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -747,7 +1744,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -815,7 +1827,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mockNumber', + models: { + mockNumber: { + defaults: { + number: '', + otp: '', + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -935,7 +1962,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2ProviderList', + models: { + oAuth2ProviderList: { + defaults: { + total: 0, + providers: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -945,16 +1985,16 @@ export class Project { * @param {string} params.authorizationUrl - URL to your application with consent screen. * @param {string[]} params.scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} params.accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} params.refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} params.publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} params.publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} params.installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} params.confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} params.verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} params.userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} params.userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} params.deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} params.defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} params.installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -965,16 +2005,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }): Promise<Models.Project>; @@ -985,16 +2025,16 @@ export class Project { * @param {string} authorizationUrl - URL to your application with consent screen. * @param {string[]} scopes - List of allowed OAuth2 scopes. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} authorizationDetailsTypes - List of accepted `authorization_details` types. Maximum of 100 types are allowed, each up to 128 characters long. - * @param {number} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. - * @param {number} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. - * @param {number} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. - * @param {number} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. - * @param {number} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. - * @param {boolean} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. + * @param {number | null} accessTokenDuration - Access token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 8 hours. + * @param {number | null} refreshTokenDuration - Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. + * @param {number | null} publicAccessTokenDuration - Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. + * @param {number | null} publicRefreshTokenDuration - Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + * @param {number | null} installationAccessTokenDuration - Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. + * @param {boolean | null} confidentialPkce - When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. * @param {string} verificationUrl - URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. - * @param {number} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. + * @param {number | null} userCodeLength - Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. * @param {string} userCodeFormat - Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. - * @param {number} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. + * @param {number | null} deviceCodeDuration - Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. * @param {string[]} defaultScopes - List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. * @param {string[]} installationScopes - List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. * @throws {AppwriteException} @@ -1006,16 +2046,16 @@ export class Project { authorizationUrl: string, scopes?: string[], authorizationDetailsTypes?: string[], - accessTokenDuration?: number, - refreshTokenDuration?: number, - publicAccessTokenDuration?: number, - publicRefreshTokenDuration?: number, - installationAccessTokenDuration?: number, - confidentialPkce?: boolean, + accessTokenDuration?: number | null, + refreshTokenDuration?: number | null, + publicAccessTokenDuration?: number | null, + publicRefreshTokenDuration?: number | null, + installationAccessTokenDuration?: number | null, + confidentialPkce?: boolean | null, verificationUrl?: string, - userCodeLength?: number, + userCodeLength?: number | null, userCodeFormat?: string, - deviceCodeDuration?: number, + deviceCodeDuration?: number | null, defaultScopes?: string[], installationScopes?: string[], ): Promise<Models.Project>; @@ -1026,16 +2066,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; } @@ -1044,16 +2084,16 @@ export class Project { string?, string[]?, string[]?, - number?, - number?, - number?, - number?, - number?, - boolean?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, string?, - number?, + (number | null)?, string?, - number?, + (number | null)?, string[]?, string[]?, ] @@ -1063,16 +2103,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1087,16 +2127,16 @@ export class Project { authorizationUrl: string; scopes?: string[]; authorizationDetailsTypes?: string[]; - accessTokenDuration?: number; - refreshTokenDuration?: number; - publicAccessTokenDuration?: number; - publicRefreshTokenDuration?: number; - installationAccessTokenDuration?: number; - confidentialPkce?: boolean; + accessTokenDuration?: number | null; + refreshTokenDuration?: number | null; + publicAccessTokenDuration?: number | null; + publicRefreshTokenDuration?: number | null; + installationAccessTokenDuration?: number | null; + confidentialPkce?: boolean | null; verificationUrl?: string; - userCodeLength?: number; + userCodeLength?: number | null; userCodeFormat?: string; - deviceCodeDuration?: number; + deviceCodeDuration?: number | null; defaultScopes?: string[]; installationScopes?: string[]; }; @@ -1106,16 +2146,16 @@ export class Project { authorizationUrl: rest[0] as string, scopes: rest[1] as string[], authorizationDetailsTypes: rest[2] as string[], - accessTokenDuration: rest[3] as number, - refreshTokenDuration: rest[4] as number, - publicAccessTokenDuration: rest[5] as number, - publicRefreshTokenDuration: rest[6] as number, - installationAccessTokenDuration: rest[7] as number, - confidentialPkce: rest[8] as boolean, + accessTokenDuration: rest[3] as number | null, + refreshTokenDuration: rest[4] as number | null, + publicAccessTokenDuration: rest[5] as number | null, + publicRefreshTokenDuration: rest[6] as number | null, + installationAccessTokenDuration: rest[7] as number | null, + confidentialPkce: rest[8] as boolean | null, verificationUrl: rest[9] as string, - userCodeLength: rest[10] as number, + userCodeLength: rest[10] as number | null, userCodeFormat: rest[11] as string, - deviceCodeDuration: rest[12] as number, + deviceCodeDuration: rest[12] as number | null, defaultScopes: rest[13] as string[], installationScopes: rest[14] as string[], }; @@ -1208,48 +2248,127 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Amazon configuration. * - * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} */ updateOAuth2Amazon(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Amazon>; /** * Update the project OAuth2 Amazon configuration. * - * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 - * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string | null} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean | null} 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<Models.OAuth2Amazon>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Amazon( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Amazon>; updateOAuth2Amazon( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Amazon> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1259,15 +2378,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1293,76 +2412,99 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Amazon', + models: { + oAuth2Amazon: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Apple configuration. * - * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} */ updateOAuth2Apple(params?: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Apple>; /** * Update the project OAuth2 Apple configuration. * - * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web - * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 - * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 - * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - * @param {string[]} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string | null} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string | null} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string | null} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Apple>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Apple( - serviceId?: string, - keyId?: string, - teamId?: string, - p8File?: string, - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + serviceId?: string | null, + keyId?: string | null, + teamId?: string | null, + p8File?: string | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Apple>; updateOAuth2Apple( paramsOrFirst?: | { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, string[]?, boolean?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Apple> { let params: { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -1372,23 +2514,23 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - serviceId?: string; - keyId?: string; - teamId?: string; - p8File?: string; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + serviceId?: string | null; + keyId?: string | null; + teamId?: string | null; + p8File?: string | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - serviceId: paramsOrFirst as string, - keyId: rest[0] as string, - teamId: rest[1] as string, - p8File: rest[2] as string, - nativeClientIds: rest[3] as string[], - enabled: rest[4] as boolean, - nativeEnabled: rest[5] as boolean, + serviceId: paramsOrFirst as string | null, + keyId: rest[0] as string | null, + teamId: rest[1] as string | null, + p8File: rest[2] as string | null, + enabled: rest[3] as boolean | null, + nativeClientIds: rest[4] as string[] | null, + nativeEnabled: rest[5] as boolean | null, }; } @@ -1396,8 +2538,8 @@ export class Project { const keyId = params.keyId; const teamId = params.teamId; const p8File = params.p8File; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/apple'; const apiPayload: Payload = {}; @@ -1413,12 +2555,12 @@ export class Project { if (typeof p8File !== 'undefined') { apiPayload['p8File'] = p8File; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -1430,48 +2572,72 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Apple', + models: { + oAuth2Apple: { + defaults: { + $id: '', + enabled: false, + serviceId: '', + keyId: '', + teamId: '', + p8File: '', + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} params.clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} */ updateOAuth2Appwrite(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Appwrite>; /** * Update the project OAuth2 Appwrite configuration. * - * @param {string} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 - * @param {string} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 + * @param {string | null} clientSecret - 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 + * @param {boolean | null} 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<Models.OAuth2Appwrite>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Appwrite( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Appwrite>; updateOAuth2Appwrite( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Appwrite> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1481,15 +2647,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1515,64 +2681,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Appwrite', + models: { + oAuth2Appwrite: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} params.prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} */ updateOAuth2Auth0(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }): Promise<Models.OAuth2Auth0>; /** * Update the project OAuth2 Auth0 configuration. * - * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq - * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF - * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com - * @param {ProjectOAuth2Auth0Prompt[]} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string | null} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string | null} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2Auth0Prompt[] | null} prompt - Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Auth0>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Auth0( - clientId?: string, - clientSecret?: string, - endpoint?: string, - prompt?: ProjectOAuth2Auth0Prompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2Auth0Prompt[] | null, ): Promise<Models.OAuth2Auth0>; updateOAuth2Auth0( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2Auth0Prompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2Auth0Prompt[] | null)?, + ] ): Promise<Models.OAuth2Auth0> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; if ( @@ -1582,27 +2769,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - prompt?: ProjectOAuth2Auth0Prompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2Auth0Prompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - prompt: rest[2] as ProjectOAuth2Auth0Prompt[], - enabled: rest[3] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2Auth0Prompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const endpoint = params.endpoint; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/auth0'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -1614,12 +2801,12 @@ export class Project { if (typeof endpoint !== 'undefined') { apiPayload['endpoint'] = endpoint; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1628,58 +2815,76 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Auth0', + models: { + oAuth2Auth0: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Authentik configuration. * - * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} */ updateOAuth2Authentik(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Authentik>; /** * Update the project OAuth2 Authentik configuration. * - * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv - * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK - * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string | null} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string | null} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean | null} 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<Models.OAuth2Authentik>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Authentik( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Authentik>; updateOAuth2Authentik( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Authentik> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -1689,17 +2894,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -1729,48 +2934,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Authentik', + models: { + oAuth2Authentik: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} */ updateOAuth2Autodesk(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Autodesk>; /** * Update the project OAuth2 Autodesk configuration. * - * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 - * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string | null} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean | null} 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<Models.OAuth2Autodesk>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Autodesk( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Autodesk>; updateOAuth2Autodesk( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Autodesk> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1780,15 +3006,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1814,44 +3040,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Autodesk', + models: { + oAuth2Autodesk: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} */ updateOAuth2Bitbucket(params?: { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitbucket>; /** * Update the project OAuth2 Bitbucket configuration. * - * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc - * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string | null} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean | null} 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<Models.OAuth2Bitbucket>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitbucket( - key?: string, - secret?: string, - enabled?: boolean, + key?: string | null, + secret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitbucket>; updateOAuth2Bitbucket( paramsOrFirst?: - { key?: string; secret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitbucket> { - let params: { key?: string; secret?: string; enabled?: boolean }; + let params: { + key?: string | null; + secret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -1860,15 +3111,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - key?: string; - secret?: string; - enabled?: boolean; + key?: string | null; + secret?: string | null; + enabled?: boolean | null; }; } else { params = { - key: paramsOrFirst as string, - secret: rest[0] as string, - enabled: rest[1] as boolean, + key: paramsOrFirst as string | null, + secret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1894,48 +3145,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitbucket', + models: { + oAuth2Bitbucket: { + defaults: { + $id: '', + enabled: false, + key: '', + secret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Bitly configuration. * - * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} */ updateOAuth2Bitly(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Bitly>; /** * Update the project OAuth2 Bitly configuration. * - * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b - * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string | null} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean | null} 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<Models.OAuth2Bitly>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Bitly( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Bitly>; updateOAuth2Bitly( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Bitly> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -1945,15 +3216,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -1979,48 +3250,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Bitly', + models: { + oAuth2Bitly: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Box configuration. * - * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} */ updateOAuth2Box(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Box>; /** * Update the project OAuth2 Box configuration. * - * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y - * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string | null} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean | null} 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<Models.OAuth2Box>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Box( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Box>; updateOAuth2Box( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Box> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2030,15 +3321,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2064,48 +3355,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Box', + models: { + oAuth2Box: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} params.clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} */ updateOAuth2Cloudflare(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Cloudflare>; /** * Update the project OAuth2 Cloudflare configuration. * - * @param {string} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 - * @param {string} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Cloudflare OAuth2 app. For example: 4b866000000000000000000000c9e4e2 + * @param {string | null} clientSecret - 'Client Secret' of Cloudflare OAuth2 app. For example: cfoc_5Q6YRl0000000000000000000000000000000000003d214f + * @param {boolean | null} 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<Models.OAuth2Cloudflare>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Cloudflare( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Cloudflare>; updateOAuth2Cloudflare( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Cloudflare> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2115,15 +3426,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2149,44 +3460,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Cloudflare', + models: { + oAuth2Cloudflare: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} */ updateOAuth2Dailymotion(params?: { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dailymotion>; /** * Update the project OAuth2 Dailymotion configuration. * - * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f - * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string | null} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean | null} 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<Models.OAuth2Dailymotion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dailymotion( - apiKey?: string, - apiSecret?: string, - enabled?: boolean, + apiKey?: string | null, + apiSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dailymotion>; updateOAuth2Dailymotion( paramsOrFirst?: - { apiKey?: string; apiSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dailymotion> { - let params: { apiKey?: string; apiSecret?: string; enabled?: boolean }; + let params: { + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2195,15 +3531,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - apiKey?: string; - apiSecret?: string; - enabled?: boolean; + apiKey?: string | null; + apiSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - apiKey: paramsOrFirst as string, - apiSecret: rest[0] as string, - enabled: rest[1] as boolean, + apiKey: paramsOrFirst as string | null, + apiSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2229,58 +3565,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dailymotion', + models: { + oAuth2Dailymotion: { + defaults: { + $id: '', + enabled: false, + apiKey: '', + apiSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Discord configuration. * - * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} params.prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} */ updateOAuth2Discord(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }): Promise<Models.OAuth2Discord>; /** * Update the project OAuth2 Discord configuration. * - * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 - * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D - * @param {ProjectOAuth2DiscordPrompt[]} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string | null} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2DiscordPrompt[] | null} prompt - Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Discord>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Discord( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2DiscordPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2DiscordPrompt[] | null, ): Promise<Models.OAuth2Discord>; updateOAuth2Discord( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2DiscordPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2DiscordPrompt[] | null)?, + ] ): Promise<Models.OAuth2Discord> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; if ( @@ -2290,24 +3646,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2DiscordPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2DiscordPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2DiscordPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2DiscordPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/discord'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2316,12 +3672,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2330,48 +3686,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Discord', + models: { + oAuth2Discord: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Disqus configuration. * - * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} */ updateOAuth2Disqus(params?: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Disqus>; /** * Update the project OAuth2 Disqus configuration. * - * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX - * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string | null} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean | null} 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<Models.OAuth2Disqus>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Disqus( - publicKey?: string, - secretKey?: string, - enabled?: boolean, + publicKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Disqus>; updateOAuth2Disqus( paramsOrFirst?: - | { publicKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Disqus> { let params: { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -2381,15 +3758,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - publicKey?: string; - secretKey?: string; - enabled?: boolean; + publicKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - publicKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + publicKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2415,44 +3792,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Disqus', + models: { + oAuth2Disqus: { + defaults: { + $id: '', + enabled: false, + publicKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} */ updateOAuth2Dropbox(params?: { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Dropbox>; /** * Update the project OAuth2 Dropbox configuration. * - * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t - * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string | null} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean | null} 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<Models.OAuth2Dropbox>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Dropbox( - appKey?: string, - appSecret?: string, - enabled?: boolean, + appKey?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Dropbox>; updateOAuth2Dropbox( paramsOrFirst?: - { appKey?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Dropbox> { - let params: { appKey?: string; appSecret?: string; enabled?: boolean }; + let params: { + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2461,15 +3863,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appKey?: string; - appSecret?: string; - enabled?: boolean; + appKey?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appKey: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appKey: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2495,48 +3897,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Dropbox', + models: { + oAuth2Dropbox: { + defaults: { + $id: '', + enabled: false, + appKey: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Etsy configuration. * - * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} */ updateOAuth2Etsy(params?: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Etsy>; /** * Update the project OAuth2 Etsy configuration. * - * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 - * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string | null} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean | null} 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<Models.OAuth2Etsy>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Etsy( - keyString?: string, - sharedSecret?: string, - enabled?: boolean, + keyString?: string | null, + sharedSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Etsy>; updateOAuth2Etsy( paramsOrFirst?: - | { keyString?: string; sharedSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Etsy> { let params: { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2546,15 +3968,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - keyString?: string; - sharedSecret?: string; - enabled?: boolean; + keyString?: string | null; + sharedSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - keyString: paramsOrFirst as string, - sharedSecret: rest[0] as string, - enabled: rest[1] as boolean, + keyString: paramsOrFirst as string | null, + sharedSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2580,44 +4002,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Etsy', + models: { + oAuth2Etsy: { + defaults: { + $id: '', + enabled: false, + keyString: '', + sharedSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Facebook configuration. * - * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} */ updateOAuth2Facebook(params?: { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Facebook>; /** * Update the project OAuth2 Facebook configuration. * - * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 - * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string | null} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean | null} 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<Models.OAuth2Facebook>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Facebook( - appId?: string, - appSecret?: string, - enabled?: boolean, + appId?: string | null, + appSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Facebook>; updateOAuth2Facebook( paramsOrFirst?: - { appId?: string; appSecret?: string; enabled?: boolean } | string, - ...rest: [string?, boolean?] + | { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Facebook> { - let params: { appId?: string; appSecret?: string; enabled?: boolean }; + let params: { + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; + }; if ( (typeof paramsOrFirst === 'undefined' && rest.length === 0) || @@ -2626,15 +4073,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - appId?: string; - appSecret?: string; - enabled?: boolean; + appId?: string | null; + appSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - appId: paramsOrFirst as string, - appSecret: rest[0] as string, - enabled: rest[1] as boolean, + appId: paramsOrFirst as string | null, + appSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2660,48 +4107,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Facebook', + models: { + oAuth2Facebook: { + defaults: { + $id: '', + enabled: false, + appId: '', + appSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Figma configuration. * - * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} */ updateOAuth2Figma(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Figma>; /** * Update the project OAuth2 Figma configuration. * - * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 - * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string | null} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean | null} 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<Models.OAuth2Figma>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Figma( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Figma>; updateOAuth2Figma( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Figma> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -2711,15 +4178,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -2745,58 +4212,74 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Figma', + models: { + oAuth2Figma: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} */ updateOAuth2FusionAuth(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2FusionAuth>; /** * Update the project OAuth2 FusionAuth configuration. * - * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 - * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc - * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string | null} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string | null} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean | null} 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<Models.OAuth2FusionAuth>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2FusionAuth( - clientId?: string, - clientSecret?: string, - endpoint?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2FusionAuth>; updateOAuth2FusionAuth( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2FusionAuth> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -2806,17 +4289,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -2846,58 +4329,79 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2FusionAuth', + models: { + oAuth2FusionAuth: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 GitHub configuration. * - * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} params.prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} */ updateOAuth2GitHub(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }): Promise<Models.OAuth2Github>; /** * Update the project OAuth2 GitHub configuration. * - * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 - * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc - * @param {ProjectOAuth2GitHubPrompt[]} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string | null} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2GitHubPrompt[] | null} prompt - Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Github>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2GitHub( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GitHubPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2GitHubPrompt[] | null, ): Promise<Models.OAuth2Github>; updateOAuth2GitHub( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2GitHubPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2GitHubPrompt[] | null)?, + ] ): Promise<Models.OAuth2Github> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; if ( @@ -2907,24 +4411,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GitHubPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2GitHubPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GitHubPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2GitHubPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/github'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -2933,12 +4437,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2947,58 +4451,75 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Github', + models: { + oAuth2Github: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} */ updateOAuth2Gitlab(params?: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Gitlab>; /** * Update the project OAuth2 Gitlab configuration. * - * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 - * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 - * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string | null} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string | null} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean | null} 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<Models.OAuth2Gitlab>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Gitlab( - applicationId?: string, - secret?: string, - endpoint?: string, - enabled?: boolean, + applicationId?: string | null, + secret?: string | null, + endpoint?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Gitlab>; updateOAuth2Gitlab( paramsOrFirst?: | { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Gitlab> { let params: { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; if ( @@ -3008,17 +4529,17 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - secret?: string; - endpoint?: string; - enabled?: boolean; + applicationId?: string | null; + secret?: string | null; + endpoint?: string | null; + enabled?: boolean | null; }; } else { params = { - applicationId: paramsOrFirst as string, - secret: rest[0] as string, - endpoint: rest[1] as string, - enabled: rest[2] as boolean, + applicationId: paramsOrFirst as string | null, + secret: rest[0] as string | null, + endpoint: rest[1] as string | null, + enabled: rest[2] as boolean | null, }; } @@ -3048,76 +4569,93 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Gitlab', + models: { + oAuth2Gitlab: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + secret: '', + endpoint: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Google configuration. * - * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} params.enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} params.nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} params.nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} */ updateOAuth2Google(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }): Promise<Models.OAuth2Google>; /** * Update the project OAuth2 Google configuration. * - * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {string[]} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. - * @param {boolean} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. - * @param {boolean} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. + * @param {string | null} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string | null} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[] | null} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean | null} enabled - Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + * @param {string[] | null} nativeClientIds - Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + * @param {boolean | null} nativeEnabled - Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Google>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Google( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2GooglePrompt[], - nativeClientIds?: string[], - enabled?: boolean, - nativeEnabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + prompt?: ProjectOAuth2GooglePrompt[] | null, + enabled?: boolean | null, + nativeClientIds?: string[] | null, + nativeEnabled?: boolean | null, ): Promise<Models.OAuth2Google>; updateOAuth2Google( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - ProjectOAuth2GooglePrompt[]?, - string[]?, - boolean?, - boolean?, + (string | null)?, + (ProjectOAuth2GooglePrompt[] | null)?, + (boolean | null)?, + (string[] | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Google> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; if ( @@ -3127,29 +4665,29 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2GooglePrompt[]; - nativeClientIds?: string[]; - enabled?: boolean; - nativeEnabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + prompt?: ProjectOAuth2GooglePrompt[] | null; + enabled?: boolean | null; + nativeClientIds?: string[] | null; + nativeEnabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2GooglePrompt[], - nativeClientIds: rest[2] as string[], - enabled: rest[3] as boolean, - nativeEnabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + prompt: rest[1] as ProjectOAuth2GooglePrompt[] | null, + enabled: rest[2] as boolean | null, + nativeClientIds: rest[3] as string[] | null, + nativeEnabled: rest[4] as boolean | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; const prompt = params.prompt; - const nativeClientIds = params.nativeClientIds; const enabled = params.enabled; + const nativeClientIds = params.nativeClientIds; const nativeEnabled = params.nativeEnabled; const apiPath = '/project/oauth2/google'; const apiPayload: Payload = {}; @@ -3162,12 +4700,12 @@ export class Project { if (typeof prompt !== 'undefined') { apiPayload['prompt'] = prompt; } - if (typeof nativeClientIds !== 'undefined') { - apiPayload['nativeClientIds'] = nativeClientIds; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof nativeClientIds !== 'undefined') { + apiPayload['nativeClientIds'] = nativeClientIds; + } if (typeof nativeEnabled !== 'undefined') { apiPayload['nativeEnabled'] = nativeEnabled; } @@ -3179,48 +4717,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Google', + models: { + oAuth2Google: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: ['consent'], + nativeEnabled: false, + nativeClientIds: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Hugging Face configuration. * - * @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. + * @param {string | null} params.clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} params.clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} */ updateOAuth2HuggingFace(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2HuggingFace>; /** * 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. + * @param {string | null} clientId - 'Client ID' of Hugging Face OAuth2 app. For example: 2ab9cff9-d711-40ad-a91e-b08a49c42d24 + * @param {string | null} clientSecret - 'Client Secret' of Hugging Face OAuth2 app. For example: oauth_app_secret_wcLhRtl000000000000000000000xbNdLt + * @param {boolean | null} 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<Models.OAuth2HuggingFace>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2HuggingFace( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2HuggingFace>; updateOAuth2HuggingFace( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2HuggingFace> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3230,15 +4791,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3264,58 +4825,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2HuggingFace', + models: { + oAuth2HuggingFace: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kakao configuration. * - * @param {string} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} params.clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} params.prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} */ updateOAuth2Kakao(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }): Promise<Models.OAuth2Kakao>; /** * Update the project OAuth2 Kakao configuration. * - * @param {string} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de - * @param {string} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - * @param {ProjectOAuth2KakaoPrompt[]} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + * @param {string | null} clientSecret - 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2KakaoPrompt[] | null} prompt - Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Kakao>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kakao( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2KakaoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2KakaoPrompt[] | null, ): Promise<Models.OAuth2Kakao>; updateOAuth2Kakao( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2KakaoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2KakaoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Kakao> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; if ( @@ -3325,24 +4906,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2KakaoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2KakaoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2KakaoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2KakaoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/kakao'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -3351,12 +4932,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3365,64 +4946,86 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kakao', + models: { + oAuth2Kakao: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. + * @param {string | null} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} */ updateOAuth2Keycloak(params?: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Keycloak>; /** * Update the project OAuth2 Keycloak configuration. * - * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO - * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com - * @param {string} realmName - Keycloak realm name. For example: appwrite-realm - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string | null} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string | null} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean | null} 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<Models.OAuth2Keycloak>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Keycloak( - clientId?: string, - clientSecret?: string, - endpoint?: string, - realmName?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + endpoint?: string | null, + realmName?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Keycloak>; updateOAuth2Keycloak( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, string?, string?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.OAuth2Keycloak> { let params: { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; if ( @@ -3432,19 +5035,19 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - endpoint?: string; - realmName?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + endpoint?: string | null; + realmName?: string | null; + enabled?: boolean | null; }; } 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, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + endpoint: rest[1] as string | null, + realmName: rest[2] as string | null, + enabled: rest[3] as boolean | null, }; } @@ -3478,48 +5081,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Keycloak', + models: { + oAuth2Keycloak: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + endpoint: '', + realmName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Kick configuration. * - * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} */ updateOAuth2Kick(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Kick>; /** * Update the project OAuth2 Kick configuration. * - * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 - * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string | null} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean | null} 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<Models.OAuth2Kick>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Kick( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Kick>; updateOAuth2Kick( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Kick> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3529,15 +5154,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3563,52 +5188,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Kick', + models: { + oAuth2Kick: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} */ updateOAuth2Linkedin(params?: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Linkedin>; /** * Update the project OAuth2 Linkedin configuration. * - * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv - * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string | null} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean | null} 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<Models.OAuth2Linkedin>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Linkedin( - clientId?: string, - primaryClientSecret?: string, - enabled?: boolean, + clientId?: string | null, + primaryClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Linkedin>; updateOAuth2Linkedin( paramsOrFirst?: | { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Linkedin> { let params: { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3618,15 +5259,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - primaryClientSecret?: string; - enabled?: boolean; + clientId?: string | null; + primaryClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - primaryClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + primaryClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3652,64 +5293,85 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Linkedin', + models: { + oAuth2Linkedin: { + defaults: { + $id: '', + enabled: false, + clientId: '', + primaryClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} params.prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} */ updateOAuth2Microsoft(params?: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }): Promise<Models.OAuth2Microsoft>; /** * Update the project OAuth2 Microsoft configuration. * - * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 - * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u - * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common - * @param {ProjectOAuth2MicrosoftPrompt[]} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string | null} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string | null} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2MicrosoftPrompt[] | null} prompt - Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Microsoft>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Microsoft( - applicationId?: string, - applicationSecret?: string, - tenant?: string, - prompt?: ProjectOAuth2MicrosoftPrompt[], - enabled?: boolean, + applicationId?: string | null, + applicationSecret?: string | null, + tenant?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2MicrosoftPrompt[] | null, ): Promise<Models.OAuth2Microsoft>; updateOAuth2Microsoft( paramsOrFirst?: | { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; } - | string, - ...rest: [string?, string?, ProjectOAuth2MicrosoftPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2MicrosoftPrompt[] | null)?, + ] ): Promise<Models.OAuth2Microsoft> { let params: { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; if ( @@ -3719,27 +5381,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - applicationId?: string; - applicationSecret?: string; - tenant?: string; - prompt?: ProjectOAuth2MicrosoftPrompt[]; - enabled?: boolean; + applicationId?: string | null; + applicationSecret?: string | null; + tenant?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2MicrosoftPrompt[] | null; }; } else { params = { - applicationId: paramsOrFirst as string, - applicationSecret: rest[0] as string, - tenant: rest[1] as string, - prompt: rest[2] as ProjectOAuth2MicrosoftPrompt[], - enabled: rest[3] as boolean, + applicationId: paramsOrFirst as string | null, + applicationSecret: rest[0] as string | null, + tenant: rest[1] as string | null, + enabled: rest[2] as boolean | null, + prompt: rest[3] as ProjectOAuth2MicrosoftPrompt[] | null, }; } const applicationId = params.applicationId; const applicationSecret = params.applicationSecret; const tenant = params.tenant; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/microsoft'; const apiPayload: Payload = {}; if (typeof applicationId !== 'undefined') { @@ -3751,12 +5413,12 @@ export class Project { if (typeof tenant !== 'undefined') { apiPayload['tenant'] = tenant; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -3765,52 +5427,70 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Microsoft', + models: { + oAuth2Microsoft: { + defaults: { + $id: '', + enabled: false, + applicationId: '', + applicationSecret: '', + prompt: [], + tenant: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Notion configuration. * - * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} */ updateOAuth2Notion(params?: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Notion>; /** * Update the project OAuth2 Notion configuration. * - * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 - * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string | null} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean | null} 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<Models.OAuth2Notion>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Notion( - oauthClientId?: string, - oauthClientSecret?: string, - enabled?: boolean, + oauthClientId?: string | null, + oauthClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Notion>; updateOAuth2Notion( paramsOrFirst?: | { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Notion> { let params: { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -3820,15 +5500,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauthClientId?: string; - oauthClientSecret?: string; - enabled?: boolean; + oauthClientId?: string | null; + oauthClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauthClientId: paramsOrFirst as string, - oauthClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauthClientId: paramsOrFirst as string | null, + oauthClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -3854,97 +5534,113 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Notion', + models: { + oAuth2Notion: { + defaults: { + $id: '', + enabled: false, + oauthClientId: '', + oauthClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Oidc configuration. * - * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} params.prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} params.maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} */ updateOAuth2Oidc(params?: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Oidc>; /** * Update the project OAuth2 Oidc configuration. * - * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG - * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV - * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration - * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize - * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token - * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo - * @param {ProjectOAuth2OidcPrompt[]} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - * @param {number} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string | null} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string | null} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string | null} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string | null} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string | null} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {ProjectOAuth2OidcPrompt[] | null} prompt - Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {number | null} maxAge - Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. + * @param {boolean | null} 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<Models.OAuth2Oidc>} * @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, + clientId?: string | null, + clientSecret?: string | null, + wellKnownURL?: string | null, + authorizationURL?: string | null, + tokenURL?: string | null, + userInfoURL?: string | null, + prompt?: ProjectOAuth2OidcPrompt[] | null, + maxAge?: number | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Oidc>; updateOAuth2Oidc( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - string?, - string?, - ProjectOAuth2OidcPrompt[]?, - number?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectOAuth2OidcPrompt[] | null)?, + (number | null)?, + (boolean | null)?, ] ): Promise<Models.OAuth2Oidc> { let params: { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; if ( @@ -3954,27 +5650,27 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - wellKnownURL?: string; - authorizationURL?: string; - tokenURL?: string; - userInfoURL?: string; - prompt?: ProjectOAuth2OidcPrompt[]; - maxAge?: number; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + wellKnownURL?: string | null; + authorizationURL?: string | null; + tokenURL?: string | null; + userInfoURL?: string | null; + prompt?: ProjectOAuth2OidcPrompt[] | null; + maxAge?: number | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - wellKnownURL: rest[1] as string, - authorizationURL: rest[2] as string, - tokenURL: rest[3] as string, - userInfoURL: rest[4] as string, - prompt: rest[5] as ProjectOAuth2OidcPrompt[], - maxAge: rest[6] as number, - enabled: rest[7] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + wellKnownURL: rest[1] as string | null, + authorizationURL: rest[2] as string | null, + tokenURL: rest[3] as string | null, + userInfoURL: rest[4] as string | null, + prompt: rest[5] as ProjectOAuth2OidcPrompt[] | null, + maxAge: rest[6] as number | null, + enabled: rest[7] as boolean | null, }; } @@ -4024,76 +5720,97 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Oidc', + models: { + oAuth2Oidc: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + wellKnownURL: '', + authorizationURL: '', + tokenURL: '', + userInfoURL: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Okta configuration. * - * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} params.prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} */ updateOAuth2Okta(params?: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }): Promise<Models.OAuth2Okta>; /** * Update the project OAuth2 Okta configuration. * - * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 - * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV - * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ - * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z - * @param {ProjectOAuth2OktaPrompt[]} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string | null} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string | null} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string | null} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2OktaPrompt[] | null} prompt - Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Okta>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Okta( - clientId?: string, - clientSecret?: string, - domain?: string, - authorizationServerId?: string, - prompt?: ProjectOAuth2OktaPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + domain?: string | null, + authorizationServerId?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2OktaPrompt[] | null, ): Promise<Models.OAuth2Okta>; updateOAuth2Okta( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; } - | string, + | string + | null, ...rest: [ - string?, - string?, - string?, - ProjectOAuth2OktaPrompt[]?, - boolean?, + (string | null)?, + (string | null)?, + (string | null)?, + (boolean | null)?, + (ProjectOAuth2OktaPrompt[] | null)?, ] ): Promise<Models.OAuth2Okta> { let params: { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; if ( @@ -4103,21 +5820,21 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - domain?: string; - authorizationServerId?: string; - prompt?: ProjectOAuth2OktaPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + domain?: string | null; + authorizationServerId?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2OktaPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - domain: rest[1] as string, - authorizationServerId: rest[2] as string, - prompt: rest[3] as ProjectOAuth2OktaPrompt[], - enabled: rest[4] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + domain: rest[1] as string | null, + authorizationServerId: rest[2] as string | null, + enabled: rest[3] as boolean | null, + prompt: rest[4] as ProjectOAuth2OktaPrompt[] | null, }; } @@ -4125,8 +5842,8 @@ export class Project { const clientSecret = params.clientSecret; const domain = params.domain; const authorizationServerId = params.authorizationServerId; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/okta'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -4141,12 +5858,12 @@ export class Project { if (typeof authorizationServerId !== 'undefined') { apiPayload['authorizationServerId'] = authorizationServerId; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4155,48 +5872,71 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Okta', + models: { + oAuth2Okta: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + domain: '', + authorizationServerId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Paypal configuration. * - * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2Paypal(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 Paypal configuration. * - * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Paypal( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2Paypal( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4206,15 +5946,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4240,48 +5980,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} */ updateOAuth2PaypalSandbox(params?: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Paypal>; /** * Update the project OAuth2 PaypalSandbox configuration. * - * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB - * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string | null} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean | null} 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<Models.OAuth2Paypal>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2PaypalSandbox( - clientId?: string, - secretKey?: string, - enabled?: boolean, + clientId?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Paypal>; updateOAuth2PaypalSandbox( paramsOrFirst?: - | { clientId?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Paypal> { let params: { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4291,15 +6051,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - secretKey?: string; - enabled?: boolean; + clientId?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4325,48 +6085,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Paypal', + models: { + oAuth2Paypal: { + defaults: { + $id: '', + enabled: false, + clientId: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Podio configuration. * - * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} */ updateOAuth2Podio(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Podio>; /** * Update the project OAuth2 Podio configuration. * - * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app - * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string | null} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean | null} 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<Models.OAuth2Podio>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Podio( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Podio>; updateOAuth2Podio( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Podio> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4376,15 +6156,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4410,48 +6190,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Podio', + models: { + oAuth2Podio: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Resend configuration. * - * @param {string} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} params.clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} */ updateOAuth2Resend(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Resend>; /** * Update the project OAuth2 Resend configuration. * - * @param {string} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 - * @param {string} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Resend OAuth2 app. For example: f47ac10b-58cc-4372-a567-0e02b2c3d479 + * @param {string | null} clientSecret - 'Client Secret' of Resend OAuth2 app. For example: 9c1e4b00000000000000000000000000000000000000000000000000a72d5f4 + * @param {boolean | null} 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<Models.OAuth2Resend>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Resend( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Resend>; updateOAuth2Resend( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Resend> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4461,15 +6261,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4495,58 +6295,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Resend', + models: { + oAuth2Resend: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} params.prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} */ updateOAuth2Salesforce(params?: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }): Promise<Models.OAuth2Salesforce>; /** * Update the project OAuth2 Salesforce configuration. * - * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq - * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 - * @param {ProjectOAuth2SalesforcePrompt[]} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string | null} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2SalesforcePrompt[] | null} prompt - Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Salesforce>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Salesforce( - customerKey?: string, - customerSecret?: string, - prompt?: ProjectOAuth2SalesforcePrompt[], - enabled?: boolean, + customerKey?: string | null, + customerSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2SalesforcePrompt[] | null, ): Promise<Models.OAuth2Salesforce>; updateOAuth2Salesforce( paramsOrFirst?: | { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2SalesforcePrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2SalesforcePrompt[] | null)?, + ] ): Promise<Models.OAuth2Salesforce> { let params: { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; if ( @@ -4556,24 +6376,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - customerSecret?: string; - prompt?: ProjectOAuth2SalesforcePrompt[]; - enabled?: boolean; + customerKey?: string | null; + customerSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2SalesforcePrompt[] | null; }; } else { params = { - customerKey: paramsOrFirst as string, - customerSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2SalesforcePrompt[], - enabled: rest[2] as boolean, + customerKey: paramsOrFirst as string | null, + customerSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2SalesforcePrompt[] | null, }; } const customerKey = params.customerKey; const customerSecret = params.customerSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/salesforce'; const apiPayload: Payload = {}; if (typeof customerKey !== 'undefined') { @@ -4582,12 +6402,12 @@ export class Project { if (typeof customerSecret !== 'undefined') { apiPayload['customerSecret'] = customerSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -4596,48 +6416,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Salesforce', + models: { + oAuth2Salesforce: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + customerSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Slack configuration. * - * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} */ updateOAuth2Slack(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Slack>; /** * Update the project OAuth2 Slack configuration. * - * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 - * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string | null} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean | null} 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<Models.OAuth2Slack>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Slack( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Slack>; updateOAuth2Slack( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Slack> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4647,15 +6488,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4681,48 +6522,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Slack', + models: { + oAuth2Slack: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Spotify configuration. * - * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} */ updateOAuth2Spotify(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Spotify>; /** * Update the project OAuth2 Spotify configuration. * - * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace - * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string | null} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean | null} 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<Models.OAuth2Spotify>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Spotify( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Spotify>; updateOAuth2Spotify( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Spotify> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4732,15 +6593,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4766,48 +6627,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Spotify', + models: { + oAuth2Spotify: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Stripe configuration. * - * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} */ updateOAuth2Stripe(params?: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Stripe>; /** * Update the project OAuth2 Stripe configuration. * - * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR - * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string | null} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean | null} 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<Models.OAuth2Stripe>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Stripe( - clientId?: string, - apiSecretKey?: string, - enabled?: boolean, + clientId?: string | null, + apiSecretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Stripe>; updateOAuth2Stripe( paramsOrFirst?: - | { clientId?: string; apiSecretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Stripe> { let params: { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -4817,15 +6698,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - apiSecretKey?: string; - enabled?: boolean; + clientId?: string | null; + apiSecretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - apiSecretKey: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + apiSecretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4851,48 +6732,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Stripe', + models: { + oAuth2Stripe: { + defaults: { + $id: '', + enabled: false, + clientId: '', + apiSecretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 TikTok configuration. * - * @param {string} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} params.clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} */ updateOAuth2TikTok(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2TikTok>; /** * Update the project OAuth2 TikTok configuration. * - * @param {string} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 - * @param {string} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + * @param {string | null} clientSecret - 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + * @param {boolean | null} 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<Models.OAuth2TikTok>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TikTok( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2TikTok>; updateOAuth2TikTok( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2TikTok> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4902,15 +6803,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -4936,52 +6837,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2TikTok', + models: { + oAuth2TikTok: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2Tradeshift(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Tradeshift( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2Tradeshift( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -4991,15 +6908,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5025,52 +6942,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} */ updateOAuth2TradeshiftSandbox(params?: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Tradeshift>; /** * Update the project OAuth2 Tradeshift Sandbox configuration. * - * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app - * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string | null} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean | null} 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<Models.OAuth2Tradeshift>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2TradeshiftSandbox( - oauth2ClientId?: string, - oauth2ClientSecret?: string, - enabled?: boolean, + oauth2ClientId?: string | null, + oauth2ClientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Tradeshift>; updateOAuth2TradeshiftSandbox( paramsOrFirst?: | { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; } - | string, - ...rest: [string?, boolean?] + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Tradeshift> { let params: { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5080,15 +7013,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - oauth2ClientId?: string; - oauth2ClientSecret?: string; - enabled?: boolean; + oauth2ClientId?: string | null; + oauth2ClientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - oauth2ClientId: paramsOrFirst as string, - oauth2ClientSecret: rest[0] as string, - enabled: rest[1] as boolean, + oauth2ClientId: paramsOrFirst as string | null, + oauth2ClientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5114,48 +7047,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Tradeshift', + models: { + oAuth2Tradeshift: { + defaults: { + $id: '', + enabled: false, + oauth2ClientId: '', + oauth2ClientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Twitch configuration. * - * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} */ updateOAuth2Twitch(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Twitch>; /** * Update the project OAuth2 Twitch configuration. * - * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p - * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string | null} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean | null} 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<Models.OAuth2Twitch>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Twitch( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Twitch>; updateOAuth2Twitch( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Twitch> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5165,15 +7118,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5199,48 +7152,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Twitch', + models: { + oAuth2Twitch: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Webflow configuration. * - * @param {string} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} params.clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} */ updateOAuth2Webflow(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Webflow>; /** * Update the project OAuth2 Webflow configuration. * - * @param {string} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd - * @param {string} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + * @param {string | null} clientSecret - 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + * @param {boolean | null} 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<Models.OAuth2Webflow>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Webflow( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Webflow>; updateOAuth2Webflow( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Webflow> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5250,15 +7223,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5284,48 +7257,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Webflow', + models: { + oAuth2Webflow: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 WordPress configuration. * - * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} */ updateOAuth2WordPress(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2WordPress>; /** * Update the project OAuth2 WordPress configuration. * - * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 - * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string | null} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean | null} 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<Models.OAuth2WordPress>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2WordPress( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2WordPress>; updateOAuth2WordPress( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2WordPress> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5335,15 +7328,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5369,48 +7362,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2WordPress', + models: { + oAuth2WordPress: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 X configuration. * - * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} */ updateOAuth2X(params?: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2X>; /** * Update the project OAuth2 X configuration. * - * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT - * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string | null} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean | null} 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<Models.OAuth2X>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2X( - customerKey?: string, - secretKey?: string, - enabled?: boolean, + customerKey?: string | null, + secretKey?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2X>; updateOAuth2X( paramsOrFirst?: - | { customerKey?: string; secretKey?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2X> { let params: { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; if ( @@ -5420,15 +7433,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - customerKey?: string; - secretKey?: string; - enabled?: boolean; + customerKey?: string | null; + secretKey?: string | null; + enabled?: boolean | null; }; } else { params = { - customerKey: paramsOrFirst as string, - secretKey: rest[0] as string, - enabled: rest[1] as boolean, + customerKey: paramsOrFirst as string | null, + secretKey: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5454,48 +7467,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2X', + models: { + oAuth2X: { + defaults: { + $id: '', + enabled: false, + customerKey: '', + secretKey: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} */ updateOAuth2Yahoo(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yahoo>; /** * Update the project OAuth2 Yahoo configuration. * - * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm - * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string | null} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean | null} 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<Models.OAuth2Yahoo>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yahoo( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yahoo>; updateOAuth2Yahoo( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yahoo> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5505,15 +7538,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5539,48 +7572,68 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yahoo', + models: { + oAuth2Yahoo: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Yandex configuration. * - * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} */ updateOAuth2Yandex(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Yandex>; /** * Update the project OAuth2 Yandex configuration. * - * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c - * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string | null} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean | null} 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<Models.OAuth2Yandex>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Yandex( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Yandex>; updateOAuth2Yandex( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Yandex> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5590,15 +7643,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5624,58 +7677,78 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Yandex', + models: { + oAuth2Yandex: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoho configuration. * - * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} params.prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} */ updateOAuth2Zoho(params?: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }): Promise<Models.OAuth2Zoho>; /** * Update the project OAuth2 Zoho configuration. * - * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B - * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e - * @param {ProjectOAuth2ZohoPrompt[]} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string | null} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean | null} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {ProjectOAuth2ZohoPrompt[] | null} prompt - Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. * @throws {AppwriteException} * @returns {Promise<Models.OAuth2Zoho>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoho( - clientId?: string, - clientSecret?: string, - prompt?: ProjectOAuth2ZohoPrompt[], - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, + prompt?: ProjectOAuth2ZohoPrompt[] | null, ): Promise<Models.OAuth2Zoho>; updateOAuth2Zoho( paramsOrFirst?: | { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; } - | string, - ...rest: [string?, ProjectOAuth2ZohoPrompt[]?, boolean?] + | string + | null, + ...rest: [ + (string | null)?, + (boolean | null)?, + (ProjectOAuth2ZohoPrompt[] | null)?, + ] ): Promise<Models.OAuth2Zoho> { let params: { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; if ( @@ -5685,24 +7758,24 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - prompt?: ProjectOAuth2ZohoPrompt[]; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + prompt?: ProjectOAuth2ZohoPrompt[] | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - prompt: rest[1] as ProjectOAuth2ZohoPrompt[], - enabled: rest[2] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, + prompt: rest[2] as ProjectOAuth2ZohoPrompt[] | null, }; } const clientId = params.clientId; const clientSecret = params.clientSecret; - const prompt = params.prompt; const enabled = params.enabled; + const prompt = params.prompt; const apiPath = '/project/oauth2/zoho'; const apiPayload: Payload = {}; if (typeof clientId !== 'undefined') { @@ -5711,12 +7784,12 @@ export class Project { if (typeof clientSecret !== 'undefined') { apiPayload['clientSecret'] = clientSecret; } - if (typeof prompt !== 'undefined') { - apiPayload['prompt'] = prompt; - } if (typeof enabled !== 'undefined') { apiPayload['enabled'] = enabled; } + if (typeof prompt !== 'undefined') { + apiPayload['prompt'] = prompt; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -5725,48 +7798,69 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoho', + models: { + oAuth2Zoho: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + prompt: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the project OAuth2 Zoom configuration. * - * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} */ updateOAuth2Zoom(params?: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }): Promise<Models.OAuth2Zoom>; /** * Update the project OAuth2 Zoom configuration. * - * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ - * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON - * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @param {string | null} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string | null} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean | null} 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<Models.OAuth2Zoom>} * @deprecated Use the object parameter style method for a better developer experience. */ updateOAuth2Zoom( - clientId?: string, - clientSecret?: string, - enabled?: boolean, + clientId?: string | null, + clientSecret?: string | null, + enabled?: boolean | null, ): Promise<Models.OAuth2Zoom>; updateOAuth2Zoom( paramsOrFirst?: - | { clientId?: string; clientSecret?: string; enabled?: boolean } - | string, - ...rest: [string?, boolean?] + | { + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; + } + | string + | null, + ...rest: [(string | null)?, (boolean | null)?] ): Promise<Models.OAuth2Zoom> { let params: { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; if ( @@ -5776,15 +7870,15 @@ export class Project { !Array.isArray(paramsOrFirst)) ) { params = (paramsOrFirst || {}) as { - clientId?: string; - clientSecret?: string; - enabled?: boolean; + clientId?: string | null; + clientSecret?: string | null; + enabled?: boolean | null; }; } else { params = { - clientId: paramsOrFirst as string, - clientSecret: rest[0] as string, - enabled: rest[1] as boolean, + clientId: paramsOrFirst as string | null, + clientSecret: rest[0] as string | null, + enabled: rest[1] as boolean | null, }; } @@ -5810,7 +7904,22 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'oAuth2Zoom', + models: { + oAuth2Zoom: { + defaults: { + $id: '', + enabled: false, + clientId: '', + clientSecret: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6082,7 +8191,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformList', + models: { + platformList: { + defaults: { + total: 0, + platforms: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6091,6 +8213,7 @@ export class Project { * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6098,6 +8221,7 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }): Promise<Models.PlatformAndroid>; /** * 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. @@ -6105,6 +8229,7 @@ export class Project { * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[]} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6113,14 +8238,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[], ): Promise<Models.PlatformAndroid>; createAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, string[]?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[]; + }; if ( paramsOrFirst && @@ -6131,18 +8267,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[]; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[], }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6167,6 +8306,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6175,15 +8317,33 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} params.platformId - Platform ID. * @param {string} params.name - Platform name. Max length: 128 chars. * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} params.fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} */ @@ -6191,13 +8351,15 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }): Promise<Models.PlatformAndroid>; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. * * @param {string} platformId - Platform ID. * @param {string} name - Platform name. Max length: 128 chars. * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string[] | null} fingerprints - SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. * @throws {AppwriteException} * @returns {Promise<Models.PlatformAndroid>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6206,14 +8368,25 @@ export class Project { platformId: string, name: string, applicationId: string, + fingerprints?: string[] | null, ): Promise<Models.PlatformAndroid>; updateAndroidPlatform( paramsOrFirst: - | { platformId: string; name: string; applicationId: string } + | { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + } | string, - ...rest: [string?, string?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.PlatformAndroid> { - let params: { platformId: string; name: string; applicationId: string }; + let params: { + platformId: string; + name: string; + applicationId: string; + fingerprints?: string[] | null; + }; if ( paramsOrFirst && @@ -6224,18 +8397,21 @@ export class Project { platformId: string; name: string; applicationId: string; + fingerprints?: string[] | null; }; } else { params = { platformId: paramsOrFirst as string, name: rest[0] as string, applicationId: rest[1] as string, + fingerprints: rest[2] as string[] | null, }; } const platformId = params.platformId; const name = params.name; const applicationId = params.applicationId; + const fingerprints = params.fingerprints; if (typeof platformId === 'undefined' || platformId === '') { throw new AppwriteException( 'Missing required parameter: "platformId"', @@ -6260,6 +8436,9 @@ export class Project { if (typeof applicationId !== 'undefined') { apiPayload['applicationId'] = applicationId; } + if (typeof fingerprints !== 'undefined') { + apiPayload['fingerprints'] = fingerprints; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -6268,7 +8447,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformAndroid', + models: { + platformAndroid: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + applicationId: '', + fingerprints: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6365,7 +8561,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6462,7 +8674,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformApple', + models: { + platformApple: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + bundleIdentifier: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6554,7 +8782,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6646,7 +8890,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformLinux', + models: { + platformLinux: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6738,7 +8998,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6830,7 +9106,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWeb', + models: { + platformWeb: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + hostname: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6931,7 +9223,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7032,7 +9340,23 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'platformWindows', + models: { + platformWindows: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + packageIdentifierName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7233,7 +9557,20 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyList', + models: { + policyList: { + defaults: { + total: 0, + policies: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7291,7 +9628,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7349,7 +9760,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7407,7 +9892,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7465,7 +10024,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7590,7 +10223,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7691,7 +10398,209 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} params.rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasskeyPolicy(params: { rpId: string }): Promise<Models.Project>; + /** + * Set the relying party ID passkeys are bound to: the domain of your application. Passkeys work on the project's web platforms on that domain or its subdomains, and on the domain itself for Apple apps. A localhost web platform enables passkeys for local development without a relying party ID. The relying party ID cannot change while users have passkeys, and any change invalidates ceremonies in progress. + * + * @param {string} rpId - Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskeyPolicy(rpId: string): Promise<Models.Project>; + updatePasskeyPolicy( + paramsOrFirst: { rpId: string } | string, + ): Promise<Models.Project> { + let params: { rpId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { rpId: string }; + } else { + params = { + rpId: paramsOrFirst as string, + }; + } + + const rpId = params.rpId; + if (typeof rpId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rpId"'); + } + const apiPath = '/project/policies/passkey'; + const apiPayload: Payload = {}; + if (typeof rpId !== 'undefined') { + apiPayload['rpId'] = rpId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7749,7 +10658,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7757,38 +10740,38 @@ export class Project { * * 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. + * @param {number | null} 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<Models.Project>} */ updatePasswordHistoryPolicy(params: { - total?: number; + total?: number | null; }): Promise<Models.Project>; /** * 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. + * @param {number | null} 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<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy(total?: number | null): Promise<Models.Project>; updatePasswordHistoryPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -7809,7 +10792,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7867,7 +10924,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7948,7 +11079,224 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} params.enabled - Enable password rotation. Disabled by default. + * @param {number} params.maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordRotationPolicy(params?: { + enabled?: boolean; + maxAge?: number; + }): Promise<Models.Project>; + /** + * Require a password reset when an email/password sign-in uses a password older than the configured maximum age. Options left out keep their current value. + * + * @param {boolean} enabled - Enable password rotation. Disabled by default. + * @param {number} maxAge - Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordRotationPolicy( + enabled?: boolean, + maxAge?: number, + ): Promise<Models.Project>; + updatePasswordRotationPolicy( + paramsOrFirst?: { enabled?: boolean; maxAge?: number } | boolean, + ...rest: [number?] + ): Promise<Models.Project> { + let params: { enabled?: boolean; maxAge?: number }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + enabled?: boolean; + maxAge?: number; + }; + } else { + params = { + enabled: paramsOrFirst as boolean, + maxAge: rest[0] as number, + }; + } + + const enabled = params.enabled; + const maxAge = params.maxAge; + const apiPath = '/project/policies/password-rotation'; + const apiPayload: Payload = {}; + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof maxAge !== 'undefined') { + apiPayload['maxAge'] = maxAge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8061,7 +11409,24 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'policyPasswordStrength', + models: { + policyPasswordStrength: { + defaults: { + $id: '', + min: 8, + uppercase: false, + lowercase: false, + number: false, + symbols: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8119,7 +11484,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8177,7 +11616,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8235,7 +11748,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8291,40 +11878,116 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} params.total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ - updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + updateUserLimitPolicy(params: { + total?: number | null; + }): Promise<Models.Project>; /** * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. + * @param {number | null} total - Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy(total?: number | null): Promise<Models.Project>; updateUserLimitPolicy( - paramsOrFirst?: { total?: number } | number, + paramsOrFirst?: { total?: number | null } | number | null, ): Promise<Models.Project> { - let params: { total?: number }; + let params: { total?: number | null }; if ( paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) ) { - params = (paramsOrFirst || {}) as { total?: number }; + params = (paramsOrFirst || {}) as { total?: number | null }; } else { params = { - total: paramsOrFirst as number, + total: paramsOrFirst as number | null, }; } @@ -8345,15 +12008,89 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} */ getPolicy(params: { policyId: ProjectPolicyId; @@ -8363,6 +12100,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8374,13 +12112,14 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. * @throws {AppwriteException} - * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail>} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy | Models.PolicyMfaFactors | Models.PolicyDenyAliasedEmail | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail | Models.PolicyPasskey>} * @deprecated Use the object parameter style method for a better developer experience. */ getPolicy( @@ -8391,6 +12130,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8402,6 +12142,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey >; getPolicy( paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId, @@ -8411,6 +12152,7 @@ export class Project { | Models.PolicyPasswordStrength | Models.PolicyPasswordPersonalData | Models.PolicyPasswordPwned + | Models.PolicyPasswordRotation | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation @@ -8422,6 +12164,7 @@ export class Project { | Models.PolicyDenyDisposableEmail | Models.PolicyDenyFreeEmail | Models.PolicyDenyCorporateEmail + | Models.PolicyPasskey > { let params: { policyId: ProjectPolicyId }; @@ -8537,7 +12280,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8618,104 +12435,179 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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. * - * @param {string} params.host - SMTP server hostname (domain) - * @param {number} params.port - SMTP server port - * @param {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} params.host - SMTP server hostname (domain) + * @param {number | null} params.port - SMTP server port + * @param {string | null} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} params.password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} params.senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} */ updateSMTP(params?: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }): Promise<Models.Project>; /** * 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. * - * @param {string} host - SMTP server hostname (domain) - * @param {number} port - SMTP server port - * @param {string} username - SMTP server username. Pass an empty string to clear a previously set value. - * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). - * @param {string} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. - * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. - * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @param {string | null} host - SMTP server hostname (domain) + * @param {number | null} port - SMTP server port + * @param {string | null} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string | null} password - SMTP server password. Pass an empty string to clear a previously set value. This property is stored securely and cannot be read in future (write-only). + * @param {string | null} senderEmail - Email address shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {ProjectSMTPSecure | null} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean | null} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} * @returns {Promise<Models.Project>} * @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, + host?: string | null, + port?: number | null, + username?: string | null, + password?: string | null, + senderEmail?: string | null, + senderName?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, + secure?: ProjectSMTPSecure | null, + enabled?: boolean | null, ): Promise<Models.Project>; updateSMTP( paramsOrFirst?: | { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; } - | string, + | string + | null, ...rest: [ - number?, - string?, - string?, - string?, - string?, - string?, - string?, - ProjectSMTPSecure?, - boolean?, + (number | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (ProjectSMTPSecure | null)?, + (boolean | null)?, ] ): Promise<Models.Project> { let params: { - host?: string; - port?: number; - username?: string; - password?: string; - senderEmail?: string; - senderName?: string; - replyToEmail?: string; - replyToName?: string; - secure?: ProjectSMTPSecure; - enabled?: boolean; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; if ( @@ -8725,29 +12617,29 @@ export class Project { !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; + host?: string | null; + port?: number | null; + username?: string | null; + password?: string | null; + senderEmail?: string | null; + senderName?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; + secure?: ProjectSMTPSecure | null; + enabled?: boolean | null; }; } else { params = { - host: paramsOrFirst as string, - port: rest[0] as number, - username: rest[1] as string, - password: rest[2] as string, - senderEmail: rest[3] as string, - senderName: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, - secure: rest[7] as ProjectSMTPSecure, - enabled: rest[8] as boolean, + host: paramsOrFirst as string | null, + port: rest[0] as number | null, + username: rest[1] as string | null, + password: rest[2] as string | null, + senderEmail: rest[3] as string | null, + senderName: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, + secure: rest[7] as ProjectSMTPSecure | null, + enabled: rest[8] as boolean | null, }; } @@ -8801,7 +12693,81 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'project', + models: { + project: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + teamId: '', + region: 'fra', + smtpEnabled: false, + smtpSenderName: '', + smtpSenderEmail: '', + smtpReplyToName: '', + smtpReplyToEmail: '', + smtpHost: '', + smtpPort: 0, + smtpUsername: '', + smtpPassword: '', + smtpSecure: '', + pingCount: 0, + pingedAt: '', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '', + }, + properties: { + authMethods: { + items: 'projectAuthMethod', + }, + services: { + items: 'projectService', + }, + protocols: { + items: 'projectProtocol', + }, + blocks: { + items: 'block', + }, + }, + }, + projectAuthMethod: { + defaults: { + enabled: true, + }, + }, + projectService: { + defaults: { + enabled: true, + }, + }, + projectProtocol: { + defaults: { + enabled: true, + }, + }, + block: { + defaults: { + $createdAt: '', + resourceType: '', + resourceId: '', + mode: 'full', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8923,7 +12889,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplateList', + models: { + emailTemplateList: { + defaults: { + total: 0, + templates: [], + }, + properties: { + templates: { + items: 'emailTemplate', + }, + }, + }, + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8931,36 +12927,36 @@ export class Project { * * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. - * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} params.senderName - Name of the email sender. - * @param {string} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} params.replyToName - Reply to name. + * @param {string | null} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} params.senderName - Name of the email sender. + * @param {string | null} params.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} */ updateEmailTemplate(params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }): Promise<Models.EmailTemplate>; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. - * @param {string} subject - Subject of the email template. Can be up to 255 characters. - * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. - * @param {string} senderName - Name of the email sender. - * @param {string} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. - * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. - * @param {string} replyToName - Reply to name. + * @param {string | null} subject - Subject of the email template. Can be up to 255 characters. + * @param {string | null} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string | null} senderName - Name of the email sender. + * @param {string | null} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string | null} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. + * @param {string | null} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise<Models.EmailTemplate>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8968,45 +12964,45 @@ export class Project { updateEmailTemplate( templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, - subject?: string, - message?: string, - senderName?: string, - senderEmail?: string, - replyToEmail?: string, - replyToName?: string, + subject?: string | null, + message?: string | null, + senderName?: string | null, + senderEmail?: string | null, + replyToEmail?: string | null, + replyToName?: string | null, ): Promise<Models.EmailTemplate>; updateEmailTemplate( paramsOrFirst: | { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; } | ProjectEmailTemplateId, ...rest: [ ProjectEmailTemplateLocale?, - string?, - string?, - string?, - string?, - string?, - string?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, ] ): Promise<Models.EmailTemplate> { let params: { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; if ( @@ -9025,23 +13021,23 @@ export class Project { params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId; locale?: ProjectEmailTemplateLocale; - subject?: string; - message?: string; - senderName?: string; - senderEmail?: string; - replyToEmail?: string; - replyToName?: string; + subject?: string | null; + message?: string | null; + senderName?: string | null; + senderEmail?: string | null; + replyToEmail?: string | null; + replyToName?: string | null; }; } else { params = { templateId: paramsOrFirst as ProjectEmailTemplateId, locale: rest[0] as ProjectEmailTemplateLocale, - subject: rest[1] as string, - message: rest[2] as string, - senderName: rest[3] as string, - senderEmail: rest[4] as string, - replyToEmail: rest[5] as string, - replyToName: rest[6] as string, + subject: rest[1] as string | null, + message: rest[2] as string | null, + senderName: rest[3] as string | null, + senderEmail: rest[4] as string | null, + replyToEmail: rest[5] as string | null, + replyToName: rest[6] as string | null, }; } @@ -9092,7 +13088,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9173,7 +13188,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'emailTemplate', + models: { + emailTemplate: { + defaults: { + templateId: '', + locale: '', + message: '', + senderName: '', + senderEmail: '', + replyToEmail: '', + replyToName: '', + subject: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9241,7 +13275,37 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9352,7 +13416,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9407,58 +13490,77 @@ export class Project { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update variable by its unique ID. * * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ updateVariable( variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, boolean?] + ...rest: [(string | null)?, (string | null)?, (boolean | null)?] ): Promise<Models.Variable> { let params: { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -9468,16 +13570,16 @@ export class Project { ) { params = (paramsOrFirst || {}) as { variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } else { params = { variableId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean, + key: rest[0] as string | null, + value: rest[1] as string | null, + secret: rest[2] as boolean | null, }; } @@ -9512,7 +13614,26 @@ export class Project { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/proxy.ts b/src/services/proxy.ts index b64891c..162a7bf 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { InvalidationType } from '../enums/invalidation-type'; @@ -106,13 +111,28 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyInvalidation', + models: { + proxyInvalidation: { + defaults: { + domain: '', + type: '', + reference: '', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -124,7 +144,7 @@ export class Proxy { /** * Get a list of all the proxy rules. 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise<Models.ProxyRuleList>} @@ -174,7 +194,43 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRuleList', + models: { + proxyRuleList: { + defaults: { + total: 0, + rules: [], + }, + properties: { + rules: { + items: 'proxyRule', + }, + }, + }, + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -232,7 +288,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -323,7 +404,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -460,7 +566,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -549,7 +680,144 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} params.domain - Domain that receives email. + * @param {string} params.functionId - ID of function to execute. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createSMTPRule(params: { + domain: string; + functionId: string; + branch?: string; + }): Promise<Models.ProxyRule>; + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. + * + * @param {string} domain - Domain that receives email. + * @param {string} functionId - ID of function to execute. + * @param {string} branch - Name of VCS branch to deploy changes automatically. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSMTPRule( + domain: string, + functionId: string, + branch?: string, + ): Promise<Models.ProxyRule>; + createSMTPRule( + paramsOrFirst: + { domain: string; functionId: string; branch?: string } | string, + ...rest: [string?, string?] + ): Promise<Models.ProxyRule> { + 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, + }; + } + + 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"', + ); + } + const apiPath = '/proxy/rules/smtp'; + const apiPayload: Payload = {}; + if (typeof domain !== 'undefined') { + apiPayload['domain'] = domain; + } + if (typeof functionId !== 'undefined') { + apiPayload['functionId'] = functionId; + } + if (typeof branch !== 'undefined') { + 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', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -602,7 +870,32 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -708,6 +1001,31 @@ export class Proxy { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'proxyRule', + models: { + proxyRule: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + domain: '', + type: '', + trigger: '', + redirectUrl: '', + redirectStatusCode: 301, + deploymentId: '', + deploymentResourceId: '', + deploymentVcsProviderBranch: '', + status: 'unverified', + logs: '', + protocol: 'http', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/sites.ts b/src/services/sites.ts index 17ddc6b..2424cc0 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -97,7 +98,79 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'siteList', + models: { + siteList: { + defaults: { + total: 0, + sites: [], + }, + properties: { + sites: { + items: 'site', + }, + }, + }, + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -477,7 +550,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -528,7 +662,47 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'frameworkList', + models: { + frameworkList: { + defaults: { + total: 0, + frameworks: [], + }, + properties: { + frameworks: { + items: 'framework', + }, + }, + }, + framework: { + defaults: { + key: '', + name: '', + buildRuntime: '', + runtimes: [], + adapters: [], + }, + properties: { + adapters: { + items: 'frameworkAdapter', + }, + }, + }, + frameworkAdapter: { + defaults: { + key: '', + installCommand: '', + buildCommand: '', + outputDirectory: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -596,7 +770,33 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'specificationList', + models: { + specificationList: { + defaults: { + total: 0, + specifications: [], + }, + properties: { + specifications: { + items: 'specification', + }, + }, + }, + specification: { + defaults: { + memory: 0, + cpus: 0, + enabled: false, + slug: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -647,7 +847,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -667,16 +928,16 @@ export class Sites { * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string[] | null} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} */ @@ -695,16 +956,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }): Promise<Models.Site>; /** * Update site by its unique ID. @@ -723,16 +984,16 @@ export class Sites { * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. - * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string | null} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. - * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. - * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. - * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string[] | null} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[] | null} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. + * @param {string | null} 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. + * @param {ProjectKeyScopes[] | null} 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<Models.Site>} * @deprecated Use the object parameter style method for a better developer experience. @@ -752,16 +1013,16 @@ export class Sites { adapter?: Adapter, fallbackFile?: string, installationId?: string, - providerRepositoryId?: string, + providerRepositoryId?: string | null, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, - providerBranches?: string[], - providerPaths?: string[], - buildSpecification?: string, + providerBranches?: string[] | null, + providerPaths?: string[] | null, + buildSpecification?: string | null, runtimeSpecification?: string, deploymentRetention?: number, - scopes?: ProjectKeyScopes[], + scopes?: ProjectKeyScopes[] | null, ): Promise<Models.Site>; update( paramsOrFirst: @@ -780,16 +1041,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; } | string, ...rest: [ @@ -806,16 +1067,16 @@ export class Sites { Adapter?, string?, string?, - string?, + (string | null)?, string?, boolean?, string?, - string[]?, - string[]?, - string?, + (string[] | null)?, + (string[] | null)?, + (string | null)?, string?, number?, - ProjectKeyScopes[]?, + (ProjectKeyScopes[] | null)?, ] ): Promise<Models.Site> { let params: { @@ -833,16 +1094,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; if ( @@ -865,16 +1126,16 @@ export class Sites { adapter?: Adapter; fallbackFile?: string; installationId?: string; - providerRepositoryId?: string; + providerRepositoryId?: string | null; providerBranch?: string; providerSilentMode?: boolean; providerRootDirectory?: string; - providerBranches?: string[]; - providerPaths?: string[]; - buildSpecification?: string; + providerBranches?: string[] | null; + providerPaths?: string[] | null; + buildSpecification?: string | null; runtimeSpecification?: string; deploymentRetention?: number; - scopes?: ProjectKeyScopes[]; + scopes?: ProjectKeyScopes[] | null; }; } else { params = { @@ -892,16 +1153,16 @@ export class Sites { adapter: rest[10] as Adapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, - providerRepositoryId: rest[13] as string, + providerRepositoryId: rest[13] as string | null, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - providerBranches: rest[17] as string[], - providerPaths: rest[18] as string[], - buildSpecification: rest[19] as string, + providerBranches: rest[17] as string[] | null, + providerPaths: rest[18] as string[] | null, + buildSpecification: rest[19] as string | null, runtimeSpecification: rest[20] as string, deploymentRetention: rest[21] as number, - scopes: rest[22] as ProjectKeyScopes[], + scopes: rest[22] as ProjectKeyScopes[] | null, }; } @@ -1022,7 +1283,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1150,7 +1472,68 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'site', + models: { + site: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + enabled: true, + live: true, + logging: true, + framework: '', + deploymentRetention: 0, + deploymentId: '', + deploymentCreatedAt: '', + deploymentScreenshotLight: '', + deploymentScreenshotDark: '', + latestDeploymentId: '', + latestDeploymentCreatedAt: '', + latestDeploymentStatus: '', + scopes: [], + vars: [], + timeout: 15, + installCommand: '', + buildCommand: '', + startCommand: '', + outputDirectory: '', + installationId: '', + providerRepositoryId: '', + providerBranch: '', + providerRootDirectory: '', + providerSilentMode: false, + providerBranches: [], + providerPaths: [], + buildSpecification: 's-1vcpu-512mb', + runtimeSpecification: 's-1vcpu-512mb', + buildRuntime: '', + }, + properties: { + vars: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1252,7 +1635,55 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deploymentList', + models: { + deploymentList: { + defaults: { + total: 0, + deployments: [], + }, + properties: { + deployments: { + items: 'deployment', + }, + }, + }, + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1479,7 +1910,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1650,7 +2118,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1765,7 +2270,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1839,7 +2381,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2098,7 +2677,44 @@ export class Sites { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'deployment', + models: { + deployment: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + type: '', + resourceId: '', + resourceType: '', + entrypoint: '', + sourceSize: 0, + buildSize: 0, + totalSize: 0, + buildId: '', + activate: false, + screenshotLight: '', + screenshotDark: '', + buildLogs: '', + buildDuration: 0, + providerRepositoryName: '', + providerRepositoryOwner: '', + providerRepositoryUrl: '', + providerCommitHash: '', + providerCommitAuthorUrl: '', + providerCommitAuthor: '', + providerCommitMessage: '', + providerCommitUrl: '', + providerBranch: '', + providerBranchUrl: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2179,7 +2795,59 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'executionList', + models: { + executionList: { + defaults: { + total: 0, + executions: [], + }, + properties: { + executions: { + items: 'execution', + }, + }, + }, + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2242,7 +2910,48 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'execution', + models: { + execution: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + resourceId: '', + resourceType: 'functions', + deploymentId: '', + requestMethod: '', + requestPath: '', + requestHeaders: [], + responseStatusCode: 0, + responseBody: '', + responseHeaders: [], + logs: '', + errors: '', + duration: 0, + }, + properties: { + requestHeaders: { + items: 'headers', + }, + responseHeaders: { + items: 'headers', + }, + }, + }, + headers: { + defaults: { + name: '', + value: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,7 +3093,37 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variableList', + models: { + variableList: { + defaults: { + total: 0, + variables: [], + }, + properties: { + variables: { + items: 'variable', + }, + }, + }, + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2510,7 +3249,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2578,7 +3336,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2586,27 +3363,27 @@ export class Sites { * * @param {string} params.siteId - Site unique ID. * @param {string} params.variableId - Variable unique ID. - * @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. + * @param {string | null} params.key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} params.value - Variable value. Max length: 8192 chars. + * @param {boolean | null} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} siteId - Site unique ID. * @param {string} variableId - Variable unique ID. - * @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. + * @param {string | null} key - Variable key. Letters, digits and underscores only, must not start with a digit. Max length: 255 chars. + * @param {string | null} value - Variable value. Max length: 8192 chars. + * @param {boolean | null} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2614,28 +3391,33 @@ export class Sites { updateVariable( siteId: string, variableId: string, - key?: string, - value?: string, - secret?: boolean, + key?: string | null, + value?: string | null, + secret?: boolean | null, ): Promise<Models.Variable>; updateVariable( paramsOrFirst: | { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; } | string, - ...rest: [string?, string?, string?, boolean?] + ...rest: [ + string?, + (string | null)?, + (string | null)?, + (boolean | null)?, + ] ): Promise<Models.Variable> { let params: { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; if ( @@ -2646,17 +3428,17 @@ export class Sites { params = (paramsOrFirst || {}) as { siteId: string; variableId: string; - key?: string; - value?: string; - secret?: boolean; + key?: string | null; + value?: string | null; + secret?: boolean | null; }; } 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, + key: rest[1] as string | null, + value: rest[2] as string | null, + secret: rest[3] as boolean | null, }; } @@ -2694,7 +3476,26 @@ export class Sites { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'variable', + models: { + variable: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + value: '', + secret: false, + resourceType: '', + resourceId: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/storage.ts b/src/services/storage.ts index eee28df..d810652 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -3,6 +3,7 @@ import { Client, type Payload, UploadProgress, + applyDefaults, } from '../client'; import type { Models } from '../models'; import { InputFile } from '../inputFile'; @@ -93,7 +94,43 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucketList', + models: { + bucketList: { + defaults: { + total: 0, + buckets: [], + }, + properties: { + buckets: { + items: 'bucket', + }, + }, + }, + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -101,7 +138,7 @@ export class Storage { * * @param {string} params.bucketId - 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 - Bucket name - * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -116,7 +153,7 @@ export class Storage { createBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -131,7 +168,7 @@ export class Storage { * * @param {string} bucketId - 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 - Bucket name - * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string[] | null} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. @@ -147,7 +184,7 @@ export class Storage { createBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, @@ -162,7 +199,7 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -175,7 +212,7 @@ export class Storage { | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, number?, @@ -189,7 +226,7 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -208,7 +245,7 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; maximumFileSize?: number; @@ -222,7 +259,7 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, maximumFileSize: rest[4] as number, @@ -296,7 +333,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -351,7 +413,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -359,13 +446,13 @@ export class Storage { * * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.name - Bucket name - * @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 {string[] | null} 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.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -374,13 +461,13 @@ export class Storage { updateBucket(params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }): Promise<Models.Bucket>; @@ -389,13 +476,13 @@ export class Storage { * * @param {string} bucketId - Bucket unique ID. * @param {string} name - Bucket name - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {number | null} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled - * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {Compression | null} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean | null} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? * @throws {AppwriteException} @@ -405,13 +492,13 @@ export class Storage { updateBucket( bucketId: string, name: string, - permissions?: string[], + permissions?: string[] | null, fileSecurity?: boolean, enabled?: boolean, - maximumFileSize?: number, + maximumFileSize?: number | null, allowedFileExtensions?: string[], - compression?: Compression, - encryption?: boolean, + compression?: Compression | null, + encryption?: boolean | null, antivirus?: boolean, transformations?: boolean, ): Promise<Models.Bucket>; @@ -420,26 +507,26 @@ export class Storage { | { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; } | string, ...rest: [ string?, - string[]?, + (string[] | null)?, boolean?, boolean?, - number?, + (number | null)?, string[]?, - Compression?, - boolean?, + (Compression | null)?, + (boolean | null)?, boolean?, boolean?, ] @@ -447,13 +534,13 @@ export class Storage { let params: { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -466,13 +553,13 @@ export class Storage { params = (paramsOrFirst || {}) as { bucketId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; fileSecurity?: boolean; enabled?: boolean; - maximumFileSize?: number; + maximumFileSize?: number | null; allowedFileExtensions?: string[]; - compression?: Compression; - encryption?: boolean; + compression?: Compression | null; + encryption?: boolean | null; antivirus?: boolean; transformations?: boolean; }; @@ -480,13 +567,13 @@ export class Storage { params = { bucketId: paramsOrFirst as string, name: rest[0] as string, - permissions: rest[1] as string[], + permissions: rest[1] as string[] | null, fileSecurity: rest[2] as boolean, enabled: rest[3] as boolean, - maximumFileSize: rest[4] as number, + maximumFileSize: rest[4] as number | null, allowedFileExtensions: rest[5] as string[], - compression: rest[6] as Compression, - encryption: rest[7] as boolean, + compression: rest[6] as Compression | null, + encryption: rest[7] as boolean | null, antivirus: rest[8] as boolean, transformations: rest[9] as boolean, }; @@ -554,7 +641,32 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'bucket', + models: { + bucket: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + fileSecurity: false, + name: '', + enabled: true, + maximumFileSize: 0, + allowedFileExtensions: [], + compression: '', + encryption: true, + antivirus: true, + transformations: true, + totalSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -712,7 +824,45 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'fileList', + models: { + fileList: { + defaults: { + total: 0, + files: [], + }, + properties: { + files: { + items: 'file', + }, + }, + }, + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -934,7 +1084,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -943,7 +1120,7 @@ export class Storage { * @param {string} params.bucketId - Bucket unique ID. * @param {string} params.fileId - File ID. * @param {string} params.name - File name. - * @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 {string[] | null} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} */ @@ -951,7 +1128,7 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }): Promise<Models.File>; /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -959,7 +1136,7 @@ export class Storage { * @param {string} bucketId - Bucket unique ID. * @param {string} fileId - File ID. * @param {string} name - File name. - * @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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise<Models.File>} * @deprecated Use the object parameter style method for a better developer experience. @@ -968,7 +1145,7 @@ export class Storage { bucketId: string, fileId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, ): Promise<Models.File>; updateFile( paramsOrFirst: @@ -976,16 +1153,16 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; } | string, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, (string[] | null)?] ): Promise<Models.File> { let params: { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; if ( @@ -997,14 +1174,14 @@ export class Storage { bucketId: string; fileId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; }; } 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[] | null, }; } @@ -1038,7 +1215,34 @@ export class Storage { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'file', + models: { + file: { + defaults: { + $id: '', + bucketId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + name: '', + folder: '', + key: '', + signature: '', + mimeType: '', + sizeOriginal: 0, + sizeActual: 0, + chunksTotal: 0, + chunksUploaded: 0, + encryption: false, + compression: 'none', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index bd8c228..adb947d 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { RelationshipType } from '../enums/relationship-type'; @@ -88,7 +93,69 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -100,7 +167,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -110,7 +177,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -121,7 +188,7 @@ export class TablesDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -132,7 +199,7 @@ export class TablesDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -142,10 +209,10 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -153,7 +220,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -167,7 +234,7 @@ export class TablesDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -176,7 +243,7 @@ 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 | null, }; } @@ -222,7 +289,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -241,7 +359,42 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -309,7 +462,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -361,7 +542,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -418,7 +616,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -507,7 +722,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -638,7 +870,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -693,7 +942,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -702,9 +1002,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -712,9 +1012,9 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -722,9 +1022,9 @@ export class TablesDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -733,9 +1033,9 @@ export class TablesDB { databaseId: string, name?: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -743,20 +1043,26 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -768,18 +1074,18 @@ export class TablesDB { databaseId: string; name?: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -822,7 +1128,58 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -883,33 +1240,33 @@ export class TablesDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -918,12 +1275,12 @@ export class TablesDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -950,7 +1307,63 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1007,11 +1420,50 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigrationList', + models: { + databaseMigrationList: { + defaults: { + total: 0, + migrations: [], + }, + properties: { + migrations: { + items: 'databaseMigration', + }, + }, + }, + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} params.databaseId - Database ID. * @param {string} params.specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1025,7 +1477,7 @@ export class TablesDB { autoCutover?: boolean; }): Promise<Models.DatabaseMigration>; /** - * 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. + * Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. * * @param {string} databaseId - Database ID. * @param {string} specification - Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -1105,7 +1557,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1178,7 +1658,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1253,7 +1761,7 @@ export class TablesDB { } /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} params.databaseId - Database ID. * @param {string} params.migrationId - Migration ID. @@ -1265,7 +1773,7 @@ export class TablesDB { migrationId: string; }): Promise<Models.DatabaseMigration>; /** - * 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. + * 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. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. 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. * * @param {string} databaseId - Database ID. * @param {string} migrationId - Migration ID. @@ -1327,7 +1835,35 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseMigration', + models: { + databaseMigration: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + databaseId: '', + specification: '', + phase: 'pending', + attempt: 0, + lastError: '', + lagDocuments: 0, + changelogWatermark: 0, + verifiedAt: '', + cutoverAt: '', + soakUntil: '', + autoCutover: true, + cutoverRequested: false, + paused: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1431,7 +1967,37 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1488,7 +2054,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1543,7 +2138,52 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1647,7 +2287,59 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'tableList', + models: { + tableList: { + defaults: { + total: 0, + tables: [], + }, + properties: { + tables: { + items: 'table', + }, + }, + }, + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1656,11 +2348,11 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - 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 - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} params.columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} */ @@ -1668,7 +2360,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1680,11 +2372,11 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - 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 - Table 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 {string[] | null} 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} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {object[]} columns - Array of column definitions to create. Each column 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 column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). * @throws {AppwriteException} * @returns {Promise<Models.Table>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1693,7 +2385,7 @@ export class TablesDB { databaseId: string, tableId: string, name: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, columns?: object[], @@ -1705,7 +2397,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1715,7 +2407,7 @@ export class TablesDB { ...rest: [ string?, string?, - string[]?, + (string[] | null)?, boolean?, boolean?, object[]?, @@ -1726,7 +2418,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1742,7 +2434,7 @@ export class TablesDB { databaseId: string; tableId: string; name: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; @@ -1753,7 +2445,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, columns: rest[5] as object[], @@ -1816,7 +2508,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1886,7 +2619,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1895,7 +2669,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.name - Table 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 {string[] | null} 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.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1906,7 +2680,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1917,7 +2691,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} name - Table 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 {string[] | null} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. @@ -1929,7 +2703,7 @@ export class TablesDB { databaseId: string, tableId: string, name?: string, - permissions?: string[], + permissions?: string[] | null, rowSecurity?: boolean, enabled?: boolean, purge?: boolean, @@ -1940,19 +2714,26 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, boolean?, boolean?] + ...rest: [ + string?, + string?, + (string[] | null)?, + boolean?, + boolean?, + boolean?, + ] ): Promise<Models.Table> { let params: { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1967,7 +2748,7 @@ export class TablesDB { databaseId: string; tableId: string; name?: string; - permissions?: string[]; + permissions?: string[] | null; rowSecurity?: boolean; enabled?: boolean; purge?: boolean; @@ -1977,7 +2758,7 @@ export class TablesDB { databaseId: paramsOrFirst as string, tableId: rest[0] as string, name: rest[1] as string, - permissions: rest[2] as string[], + permissions: rest[2] as string[] | null, rowSecurity: rest[3] as boolean, enabled: rest[4] as boolean, purge: rest[5] as boolean, @@ -2028,7 +2809,48 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'table', + models: { + table: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + rowSecurity: false, + columns: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2201,7 +3023,20 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnList', + models: { + columnList: { + defaults: { + total: 0, + columns: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2212,9 +3047,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2224,9 +3059,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnBigint>; /** @@ -2237,9 +3072,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} @@ -2250,9 +3085,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnBigint>; createBigIntColumn( @@ -2262,9 +3097,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -2272,9 +3107,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnBigint> { @@ -2283,9 +3118,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -2299,9 +3134,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -2310,9 +3145,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -2373,7 +3208,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2384,10 +3236,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} */ @@ -2396,10 +3248,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnBigint>; /** * Update a bigint column. Changing the `default` value will not update already existing rows. @@ -2409,10 +3261,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBigint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2422,10 +3274,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnBigint>; updateBigIntColumn( paramsOrFirst: @@ -2434,20 +3286,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnBigint> { let params: { @@ -2455,10 +3307,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -2471,10 +3323,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -2482,10 +3334,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -2549,7 +3401,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBigint', + models: { + columnBigint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2560,7 +3429,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2570,7 +3439,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }): Promise<Models.ColumnBoolean>; /** @@ -2581,7 +3450,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} @@ -2592,7 +3461,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, + xdefault?: boolean | null, array?: boolean, ): Promise<Models.ColumnBoolean>; createBooleanColumn( @@ -2602,18 +3471,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, boolean?, boolean?] + ...rest: [string?, string?, boolean?, (boolean | null)?, boolean?] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; @@ -2627,7 +3496,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; + xdefault?: boolean | null; array?: boolean; }; } else { @@ -2636,7 +3505,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, + xdefault: rest[3] as boolean | null, array: rest[4] as boolean, }; } @@ -2690,7 +3559,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2700,8 +3586,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {boolean | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} */ @@ -2710,8 +3596,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }): Promise<Models.ColumnBoolean>; /** * Update a boolean column. Changing the `default` value will not update already existing rows. @@ -2720,8 +3606,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {boolean | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnBoolean>} * @deprecated Use the object parameter style method for a better developer experience. @@ -2731,8 +3617,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: boolean, - newKey?: string, + xdefault?: boolean | null, + newKey?: string | null, ): Promise<Models.ColumnBoolean>; updateBooleanColumn( paramsOrFirst: @@ -2741,19 +3627,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, boolean?, string?] + ...rest: [ + string?, + string?, + boolean?, + (boolean | null)?, + (string | null)?, + ] ): Promise<Models.ColumnBoolean> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; if ( @@ -2766,8 +3658,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: boolean; - newKey?: string; + xdefault?: boolean | null; + newKey?: string | null; }; } else { params = { @@ -2775,8 +3667,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as boolean, - newKey: rest[4] as string, + xdefault: rest[3] as boolean | null, + newKey: rest[4] as string | null, }; } @@ -2832,7 +3724,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnBoolean', + models: { + columnBoolean: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2842,7 +3751,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2852,7 +3761,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnDatetime>; /** @@ -2862,7 +3771,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} @@ -2873,7 +3782,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnDatetime>; createDatetimeColumn( @@ -2883,18 +3792,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -2908,7 +3817,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -2917,7 +3826,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -2971,7 +3880,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2981,8 +3907,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} */ @@ -2991,8 +3917,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnDatetime>; /** * Update a date time column. Changing the `default` value will not update already existing rows. @@ -3001,8 +3927,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnDatetime>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3012,8 +3938,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnDatetime>; updateDatetimeColumn( paramsOrFirst: @@ -3022,19 +3948,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnDatetime> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3047,8 +3979,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3056,8 +3988,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3113,7 +4045,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnDatetime', + models: { + columnDatetime: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3124,7 +4073,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3134,7 +4083,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEmail>; /** @@ -3145,7 +4094,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} @@ -3156,7 +4105,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEmail>; createEmailColumn( @@ -3166,18 +4115,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3191,7 +4140,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3200,7 +4149,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -3253,7 +4202,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3264,8 +4231,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} */ @@ -3274,8 +4241,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEmail>; /** * Update an email column. Changing the `default` value will not update already existing rows. @@ -3285,8 +4252,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEmail>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3296,8 +4263,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEmail>; updateEmailColumn( paramsOrFirst: @@ -3306,19 +4273,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEmail> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3331,8 +4304,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3340,8 +4313,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -3397,7 +4370,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEmail', + models: { + columnEmail: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'email', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3408,7 +4399,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Array of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3419,7 +4410,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnEnum>; /** @@ -3430,7 +4421,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Array of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} @@ -3442,7 +4433,7 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnEnum>; createEnumColumn( @@ -3453,11 +4444,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, boolean?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + boolean?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3465,7 +4463,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -3480,7 +4478,7 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -3490,7 +4488,7 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, }; } @@ -3552,7 +4550,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3564,8 +4581,8 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {string[]} params.elements - Updated list of enum values. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} */ @@ -3575,8 +4592,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnEnum>; /** * Update an enum column. Changing the `default` value will not update already existing rows. @@ -3587,8 +4604,8 @@ export class TablesDB { * @param {string} key - Column Key. * @param {string[]} elements - Updated list of enum values. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnEnum>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3599,8 +4616,8 @@ export class TablesDB { key: string, elements: string[], required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnEnum>; updateEnumColumn( paramsOrFirst: @@ -3610,11 +4627,18 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, string[]?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + string[]?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnEnum> { let params: { databaseId: string; @@ -3622,8 +4646,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -3637,8 +4661,8 @@ export class TablesDB { key: string; elements: string[]; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -3647,8 +4671,8 @@ export class TablesDB { key: rest[1] as string, elements: rest[2] as string[], required: rest[3] as boolean, - xdefault: rest[4] as string, - newKey: rest[5] as string, + xdefault: rest[4] as string | null, + newKey: rest[5] as string | null, }; } @@ -3713,7 +4737,26 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnEnum', + models: { + columnEnum: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + elements: [], + format: 'enum', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3724,9 +4767,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {number | null} params.xdefault - Default value. Cannot be set when required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3736,9 +4779,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }): Promise<Models.ColumnFloat>; /** @@ -3749,9 +4792,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {number | null} xdefault - Default value. Cannot be set when required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} @@ -3762,9 +4805,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number, - max?: number, - xdefault?: number, + min?: number | null, + max?: number | null, + xdefault?: number | null, array?: boolean, ): Promise<Models.ColumnFloat>; createFloatColumn( @@ -3774,9 +4817,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; } | string, @@ -3784,9 +4827,9 @@ export class TablesDB { string?, string?, boolean?, - number?, - number?, - number?, + (number | null)?, + (number | null)?, + (number | null)?, boolean?, ] ): Promise<Models.ColumnFloat> { @@ -3795,9 +4838,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; @@ -3811,9 +4854,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number; - max?: number; - xdefault?: number; + min?: number | null; + max?: number | null; + xdefault?: number | null; array?: boolean; }; } else { @@ -3822,9 +4865,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | null, + max: rest[4] as number | null, + xdefault: rest[5] as number | null, array: rest[6] as boolean, }; } @@ -3885,7 +4928,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3896,10 +4956,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | null} params.xdefault - Default value. Cannot be set when required. + * @param {number | null} params.min - Minimum value + * @param {number | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} */ @@ -3908,10 +4968,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }): Promise<Models.ColumnFloat>; /** * Update a float column. Changing the `default` value will not update already existing rows. @@ -3921,10 +4981,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | null} xdefault - Default value. Cannot be set when required. + * @param {number | null} min - Minimum value + * @param {number | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnFloat>} * @deprecated Use the object parameter style method for a better developer experience. @@ -3934,10 +4994,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number, - min?: number, - max?: number, - newKey?: string, + xdefault?: number | null, + min?: number | null, + max?: number | null, + newKey?: string | null, ): Promise<Models.ColumnFloat>; updateFloatColumn( paramsOrFirst: @@ -3946,20 +5006,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - number?, - number?, - number?, - string?, + (number | null)?, + (number | null)?, + (number | null)?, + (string | null)?, ] ): Promise<Models.ColumnFloat> { let params: { @@ -3967,10 +5027,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; if ( @@ -3983,10 +5043,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number; - min?: number; - max?: number; - newKey?: string; + xdefault?: number | null; + min?: number | null; + max?: number | null; + newKey?: string | null; }; } else { params = { @@ -3994,10 +5054,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, - newKey: rest[6] as string, + xdefault: rest[3] as number | null, + min: rest[4] as number | null, + max: rest[5] as number | null, + newKey: rest[6] as string | null, }; } @@ -4061,7 +5121,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnFloat', + models: { + columnFloat: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4072,9 +5149,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4084,9 +5161,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }): Promise<Models.ColumnInteger>; /** @@ -4097,9 +5174,9 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} @@ -4110,9 +5187,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - min?: number | bigint, - max?: number | bigint, - xdefault?: number | bigint, + min?: number | bigint | null, + max?: number | bigint | null, + xdefault?: number | bigint | null, array?: boolean, ): Promise<Models.ColumnInteger>; createIntegerColumn( @@ -4122,9 +5199,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; } | string, @@ -4132,9 +5209,9 @@ export class TablesDB { string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, boolean?, ] ): Promise<Models.ColumnInteger> { @@ -4143,9 +5220,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; @@ -4159,9 +5236,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - min?: number | bigint; - max?: number | bigint; - xdefault?: number | bigint; + min?: number | bigint | null; + max?: number | bigint | null; + xdefault?: number | bigint | null; array?: boolean; }; } else { @@ -4170,9 +5247,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number | bigint, - max: rest[4] as number | bigint, - xdefault: rest[5] as number | bigint, + min: rest[3] as number | bigint | null, + max: rest[4] as number | bigint | null, + xdefault: rest[5] as number | bigint | null, array: rest[6] as boolean, }; } @@ -4234,7 +5311,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4245,10 +5339,10 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} params.min - Minimum value - * @param {number | bigint} params.max - Maximum value - * @param {string} params.newKey - New Column Key. + * @param {number | bigint | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} params.min - Minimum value + * @param {number | bigint | null} params.max - Maximum value + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} */ @@ -4257,10 +5351,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }): Promise<Models.ColumnInteger>; /** * Update an integer column. Changing the `default` value will not update already existing rows. @@ -4270,10 +5364,10 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. - * @param {number | bigint} min - Minimum value - * @param {number | bigint} max - Maximum value - * @param {string} newKey - New Column Key. + * @param {number | bigint | null} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint | null} min - Minimum value + * @param {number | bigint | null} max - Maximum value + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnInteger>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4283,10 +5377,10 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number | bigint, - min?: number | bigint, - max?: number | bigint, - newKey?: string, + xdefault?: number | bigint | null, + min?: number | bigint | null, + max?: number | bigint | null, + newKey?: string | null, ): Promise<Models.ColumnInteger>; updateIntegerColumn( paramsOrFirst: @@ -4295,20 +5389,20 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; } | string, ...rest: [ string?, string?, boolean?, - (number | bigint)?, - (number | bigint)?, - (number | bigint)?, - string?, + (number | bigint | null)?, + (number | bigint | null)?, + (number | bigint | null)?, + (string | null)?, ] ): Promise<Models.ColumnInteger> { let params: { @@ -4316,10 +5410,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; if ( @@ -4332,10 +5426,10 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number | bigint; - min?: number | bigint; - max?: number | bigint; - newKey?: string; + xdefault?: number | bigint | null; + min?: number | bigint | null; + max?: number | bigint | null; + newKey?: string | null; }; } else { params = { @@ -4343,10 +5437,10 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number | bigint, - min: rest[4] as number | bigint, - max: rest[5] as number | bigint, - newKey: rest[6] as string, + xdefault: rest[3] as number | bigint | null, + min: rest[4] as number | bigint | null, + max: rest[5] as number | bigint | null, + newKey: rest[6] as string | null, }; } @@ -4410,7 +5504,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnInteger', + models: { + columnInteger: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4421,7 +5532,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4431,7 +5542,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnIp>; /** @@ -4442,7 +5553,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} @@ -4453,7 +5564,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnIp>; createIpColumn( @@ -4463,18 +5574,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -4488,7 +5599,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -4497,7 +5608,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -4550,7 +5661,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4561,8 +5690,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} */ @@ -4571,8 +5700,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnIp>; /** * Update an ip column. Changing the `default` value will not update already existing rows. @@ -4582,8 +5711,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnIp>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4593,8 +5722,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnIp>; updateIpColumn( paramsOrFirst: @@ -4603,19 +5732,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnIp> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -4628,8 +5763,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -4637,8 +5772,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -4694,7 +5829,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIp', + models: { + columnIp: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'ip', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4704,7 +5857,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4713,7 +5866,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnLine>; /** * Create a geometric line column. @@ -4722,7 +5875,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4732,7 +5885,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnLine>; createLineColumn( paramsOrFirst: @@ -4741,17 +5894,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -4764,7 +5917,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -4772,7 +5925,7 @@ export class TablesDB { 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[][] | null, }; } @@ -4820,7 +5973,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4830,8 +6000,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} */ @@ -4840,8 +6010,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnLine>; /** * Update a line column. Changing the `default` value will not update already existing rows. @@ -4850,8 +6020,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLine>} * @deprecated Use the object parameter style method for a better developer experience. @@ -4861,8 +6031,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnLine>; updateLineColumn( paramsOrFirst: @@ -4871,19 +6041,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLine> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -4896,8 +6072,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -4905,8 +6081,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -4957,7 +6133,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLine', + models: { + columnLine: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4968,7 +6161,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -4979,7 +6172,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnLongtext>; @@ -4991,7 +6184,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5003,7 +6196,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnLongtext>; @@ -5014,19 +6207,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5041,7 +6241,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5051,7 +6251,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5110,7 +6310,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5121,8 +6338,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} */ @@ -5131,8 +6348,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnLongtext>; /** * Update a longtext column. Changing the `default` value will not update already existing rows. @@ -5142,8 +6359,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnLongtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5153,8 +6370,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnLongtext>; updateLongtextColumn( paramsOrFirst: @@ -5163,19 +6380,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnLongtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5188,8 +6411,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5197,8 +6420,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5254,7 +6477,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnLongtext', + models: { + columnLongtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5265,7 +6505,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5276,7 +6516,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnMediumtext>; @@ -5288,7 +6528,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -5300,7 +6540,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnMediumtext>; @@ -5311,19 +6551,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5338,7 +6585,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -5348,7 +6595,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -5407,7 +6654,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5418,8 +6682,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} */ @@ -5428,8 +6692,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnMediumtext>; /** * Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -5439,8 +6703,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnMediumtext>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5450,8 +6714,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnMediumtext>; updateMediumtextColumn( paramsOrFirst: @@ -5460,19 +6724,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnMediumtext> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -5485,8 +6755,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -5494,8 +6764,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -5551,7 +6821,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnMediumtext', + models: { + columnMediumtext: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5561,7 +6848,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5570,7 +6857,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }): Promise<Models.ColumnPoint>; /** * Create a geometric point column. @@ -5579,7 +6866,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5589,7 +6876,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], + xdefault?: number[] | null, ): Promise<Models.ColumnPoint>; createPointColumn( paramsOrFirst: @@ -5598,17 +6885,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; } | string, - ...rest: [string?, string?, boolean?, number[]?] + ...rest: [string?, string?, boolean?, (number[] | null)?] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; if ( @@ -5621,7 +6908,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; + xdefault?: number[] | null; }; } else { params = { @@ -5629,7 +6916,7 @@ export class TablesDB { 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[] | null, }; } @@ -5677,7 +6964,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5687,8 +6991,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {number[] | null} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} */ @@ -5697,8 +7001,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }): Promise<Models.ColumnPoint>; /** * Update a point column. Changing the `default` value will not update already existing rows. @@ -5707,8 +7011,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {number[] | null} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPoint>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5718,8 +7022,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: number[], - newKey?: string, + xdefault?: number[] | null, + newKey?: string | null, ): Promise<Models.ColumnPoint>; updatePointColumn( paramsOrFirst: @@ -5728,19 +7032,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, number[]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (number[] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPoint> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; if ( @@ -5753,8 +7063,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: number[]; - newKey?: string; + xdefault?: number[] | null; + newKey?: string | null; }; } else { params = { @@ -5762,8 +7072,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number[], - newKey: rest[4] as string, + xdefault: rest[3] as number[] | null, + newKey: rest[4] as string | null, }; } @@ -5814,7 +7124,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPoint', + models: { + columnPoint: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5824,7 +7151,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5833,7 +7160,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }): Promise<Models.ColumnPolygon>; /** * Create a geometric polygon column. @@ -5842,7 +7169,7 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5852,7 +7179,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], + xdefault?: any[][] | null, ): Promise<Models.ColumnPolygon>; createPolygonColumn( paramsOrFirst: @@ -5861,17 +7188,17 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?] + ...rest: [string?, string?, boolean?, (any[][] | null)?] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; if ( @@ -5884,7 +7211,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; + xdefault?: any[][] | null; }; } else { params = { @@ -5892,7 +7219,7 @@ export class TablesDB { 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[][] | null, }; } @@ -5941,7 +7268,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -5951,8 +7295,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {any[][]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {any[][] | null} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} */ @@ -5961,8 +7305,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }): Promise<Models.ColumnPolygon>; /** * Update a polygon column. Changing the `default` value will not update already existing rows. @@ -5971,8 +7315,8 @@ export class TablesDB { * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {any[][]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {any[][] | null} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnPolygon>} * @deprecated Use the object parameter style method for a better developer experience. @@ -5982,8 +7326,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: any[][], - newKey?: string, + xdefault?: any[][] | null, + newKey?: string | null, ): Promise<Models.ColumnPolygon>; updatePolygonColumn( paramsOrFirst: @@ -5992,19 +7336,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, any[][]?, string?] + ...rest: [ + string?, + string?, + boolean?, + (any[][] | null)?, + (string | null)?, + ] ): Promise<Models.ColumnPolygon> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; if ( @@ -6017,8 +7367,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: any[][]; - newKey?: string; + xdefault?: any[][] | null; + newKey?: string | null; }; } else { params = { @@ -6026,8 +7376,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as any[][], - newKey: rest[4] as string, + xdefault: rest[3] as any[][] | null, + newKey: rest[4] as string | null, }; } @@ -6078,7 +7428,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnPolygon', + models: { + columnPolygon: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6090,8 +7457,8 @@ export class TablesDB { * @param {string} params.relatedTableId - Related Table ID. * @param {RelationshipType} params.type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} params.twoWay - Is Two Way? - * @param {string} params.key - Column Key. - * @param {string} params.twoWayKey - Two Way Column Key. + * @param {string | null} params.key - Column Key. + * @param {string | null} params.twoWayKey - Two Way Column Key. * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6102,8 +7469,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }): Promise<Models.ColumnRelationship>; /** @@ -6115,8 +7482,8 @@ export class TablesDB { * @param {string} relatedTableId - Related Table ID. * @param {RelationshipType} type - Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. * @param {boolean} twoWay - Is Two Way? - * @param {string} key - Column Key. - * @param {string} twoWayKey - Two Way Column Key. + * @param {string | null} key - Column Key. + * @param {string | null} twoWayKey - Two Way Column Key. * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} @@ -6128,8 +7495,8 @@ export class TablesDB { relatedTableId: string, type: RelationshipType, twoWay?: boolean, - key?: string, - twoWayKey?: string, + key?: string | null, + twoWayKey?: string | null, onDelete?: RelationMutate, ): Promise<Models.ColumnRelationship>; createRelationshipColumn( @@ -6140,8 +7507,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; } | string, @@ -6150,8 +7517,8 @@ export class TablesDB { string?, RelationshipType?, boolean?, - string?, - string?, + (string | null)?, + (string | null)?, RelationMutate?, ] ): Promise<Models.ColumnRelationship> { @@ -6161,8 +7528,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; @@ -6177,8 +7544,8 @@ export class TablesDB { relatedTableId: string; type: RelationshipType; twoWay?: boolean; - key?: string; - twoWayKey?: string; + key?: string | null; + twoWayKey?: string | null; onDelete?: RelationMutate; }; } else { @@ -6188,8 +7555,8 @@ export class TablesDB { relatedTableId: rest[1] as string, type: rest[2] as RelationshipType, twoWay: rest[3] as boolean, - key: rest[4] as string, - twoWayKey: rest[5] as string, + key: rest[4] as string | null, + twoWayKey: rest[5] as string | null, onDelete: rest[6] as RelationMutate, }; } @@ -6251,7 +7618,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6261,8 +7650,8 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. - * @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} params.newKey - New Column Key. + * @param {RelationMutate | null} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} */ @@ -6270,8 +7659,8 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }): Promise<Models.ColumnRelationship>; /** * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -6280,8 +7669,8 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {string} key - Column Key. - * @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. - * @param {string} newKey - New Column Key. + * @param {RelationMutate | null} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnRelationship>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6290,8 +7679,8 @@ export class TablesDB { databaseId: string, tableId: string, key: string, - onDelete?: RelationMutate, - newKey?: string, + onDelete?: RelationMutate | null, + newKey?: string | null, ): Promise<Models.ColumnRelationship>; updateRelationshipColumn( paramsOrFirst: @@ -6299,18 +7688,18 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, RelationMutate?, string?] + ...rest: [string?, string?, (RelationMutate | null)?, (string | null)?] ): Promise<Models.ColumnRelationship> { let params: { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; if ( @@ -6322,16 +7711,16 @@ export class TablesDB { databaseId: string; tableId: string; key: string; - onDelete?: RelationMutate; - newKey?: string; + onDelete?: RelationMutate | null; + newKey?: string | null; }; } 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, + onDelete: rest[2] as RelationMutate | null, + newKey: rest[3] as string | null, }; } @@ -6373,7 +7762,29 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnRelationship', + models: { + columnRelationship: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + relationType: '', + twoWay: false, + twoWayKey: '', + onDelete: 'restrict', + side: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6385,7 +7796,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for text columns, in number of characters. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6398,7 +7809,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnString>; @@ -6411,7 +7822,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for text columns, in number of characters. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6424,7 +7835,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnString>; @@ -6436,7 +7847,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -6446,7 +7857,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -6457,7 +7868,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6473,7 +7884,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6484,7 +7895,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -6549,7 +7960,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6560,9 +7989,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the string column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the string column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. @@ -6572,9 +8001,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnString>; /** * Update a string column. Changing the `default` value will not update already existing rows. @@ -6584,9 +8013,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the string column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the string column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnString>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6596,9 +8025,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnString>; updateStringColumn( paramsOrFirst: @@ -6607,21 +8036,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnString> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -6634,9 +8070,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -6644,9 +8080,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -6706,7 +8142,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnString', + models: { + columnString: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6717,7 +8171,7 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6728,7 +8182,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnText>; @@ -6740,7 +8194,7 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -6752,7 +8206,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnText>; @@ -6763,19 +8217,26 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?, boolean?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + boolean?, + boolean?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6790,7 +8251,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -6800,7 +8261,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, encrypt: rest[5] as boolean, }; @@ -6858,7 +8319,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -6869,8 +8347,8 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} */ @@ -6879,8 +8357,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnText>; /** * Update a text column. Changing the `default` value will not update already existing rows. @@ -6890,8 +8368,8 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnText>} * @deprecated Use the object parameter style method for a better developer experience. @@ -6901,8 +8379,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnText>; updateTextColumn( paramsOrFirst: @@ -6911,19 +8389,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnText> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -6936,8 +8420,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -6945,8 +8429,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7002,7 +8486,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnText', + models: { + columnText: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7013,7 +8514,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7023,7 +8524,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }): Promise<Models.ColumnUrl>; /** @@ -7034,7 +8535,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} @@ -7045,7 +8546,7 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, ): Promise<Models.ColumnUrl>; createUrlColumn( @@ -7055,18 +8556,18 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; } | string, - ...rest: [string?, string?, boolean?, string?, boolean?] + ...rest: [string?, string?, boolean?, (string | null)?, boolean?] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; @@ -7080,7 +8581,7 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; }; } else { @@ -7089,7 +8590,7 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, + xdefault: rest[3] as string | null, array: rest[4] as boolean, }; } @@ -7142,7 +8643,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7153,8 +8672,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} */ @@ -7163,8 +8682,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }): Promise<Models.ColumnUrl>; /** * Update an url column. Changing the `default` value will not update already existing rows. @@ -7174,8 +8693,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnUrl>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7185,8 +8704,8 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - newKey?: string, + xdefault?: string | null, + newKey?: string | null, ): Promise<Models.ColumnUrl>; updateUrlColumn( paramsOrFirst: @@ -7195,19 +8714,25 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (string | null)?, + ] ): Promise<Models.ColumnUrl> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; if ( @@ -7220,8 +8745,8 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - newKey?: string; + xdefault?: string | null; + newKey?: string | null; }; } else { params = { @@ -7229,8 +8754,8 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - newKey: rest[4] as string, + xdefault: rest[3] as string | null, + newKey: rest[4] as string | null, }; } @@ -7286,7 +8811,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnUrl', + models: { + columnUrl: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + format: 'url', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7298,7 +8841,7 @@ export class TablesDB { * @param {string} params.key - Column Key. * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7310,7 +8853,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }): Promise<Models.ColumnVarchar>; @@ -7323,7 +8866,7 @@ export class TablesDB { * @param {string} key - Column Key. * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. * @throws {AppwriteException} @@ -7336,7 +8879,7 @@ export class TablesDB { key: string, size: number, required: boolean, - xdefault?: string, + xdefault?: string | null, array?: boolean, encrypt?: boolean, ): Promise<Models.ColumnVarchar>; @@ -7348,7 +8891,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; } @@ -7358,7 +8901,7 @@ export class TablesDB { string?, number?, boolean?, - string?, + (string | null)?, boolean?, boolean?, ] @@ -7369,7 +8912,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7385,7 +8928,7 @@ export class TablesDB { key: string; size: number; required: boolean; - xdefault?: string; + xdefault?: string | null; array?: boolean; encrypt?: boolean; }; @@ -7396,7 +8939,7 @@ export class TablesDB { key: rest[1] as string, size: rest[2] as number, required: rest[3] as boolean, - xdefault: rest[4] as string, + xdefault: rest[4] as string | null, array: rest[5] as boolean, encrypt: rest[6] as boolean, }; @@ -7462,7 +9005,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7473,9 +9034,9 @@ export class TablesDB { * @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). * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} params.size - Maximum size of the varchar column. - * @param {string} params.newKey - New Column Key. + * @param {string | null} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} params.size - Maximum size of the varchar column. + * @param {string | null} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} */ @@ -7484,9 +9045,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }): Promise<Models.ColumnVarchar>; /** * Update a varchar column. Changing the `default` value will not update already existing rows. @@ -7496,9 +9057,9 @@ export class TablesDB { * @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). * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. - * @param {number} size - Maximum size of the varchar column. - * @param {string} newKey - New Column Key. + * @param {string | null} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number | null} size - Maximum size of the varchar column. + * @param {string | null} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise<Models.ColumnVarchar>} * @deprecated Use the object parameter style method for a better developer experience. @@ -7508,9 +9069,9 @@ export class TablesDB { tableId: string, key: string, required: boolean, - xdefault?: string, - size?: number, - newKey?: string, + xdefault?: string | null, + size?: number | null, + newKey?: string | null, ): Promise<Models.ColumnVarchar>; updateVarcharColumn( paramsOrFirst: @@ -7519,21 +9080,28 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; } | string, - ...rest: [string?, string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.ColumnVarchar> { let params: { databaseId: string; tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; if ( @@ -7546,9 +9114,9 @@ export class TablesDB { tableId: string; key: string; required: boolean; - xdefault?: string; - size?: number; - newKey?: string; + xdefault?: string | null; + size?: number | null; + newKey?: string | null; }; } else { params = { @@ -7556,9 +9124,9 @@ export class TablesDB { tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as string, - size: rest[4] as number, - newKey: rest[5] as string, + xdefault: rest[3] as string | null, + size: rest[4] as number | null, + newKey: rest[5] as string | null, }; } @@ -7618,7 +9186,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnVarchar', + models: { + columnVarchar: { + defaults: { + key: '', + type: '', + error: '', + required: false, + $createdAt: '', + $updatedAt: '', + size: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -7947,12 +9533,43 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndexList', + models: { + columnIndexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'columnIndex', + }, + }, + }, + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -7975,7 +9592,7 @@ export class TablesDB { }): Promise<Models.ColumnIndex>; /** * 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`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. * * @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). @@ -8109,7 +9726,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8194,7 +9831,27 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'columnIndex', + models: { + columnIndex: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + status: '', + error: '', + columns: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8405,7 +10062,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8415,8 +10101,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} params.rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row 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). - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -8427,8 +10113,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -8437,8 +10123,8 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {string} rowId - Row 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 {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row 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). - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string[] | null} 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). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8450,8 +10136,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8462,8 +10148,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -8472,8 +10158,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -8483,8 +10169,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -8499,8 +10185,8 @@ export class TablesDB { data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -8510,8 +10196,8 @@ export class TablesDB { data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -8561,7 +10247,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8570,7 +10274,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} params.rows - Array of rows data as JSON objects. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8578,7 +10282,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8586,7 +10290,7 @@ export class TablesDB { * @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). Make sure to define columns before creating rows. * @param {object[]} rows - Array of rows data as JSON objects. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8595,7 +10299,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; createRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8603,16 +10307,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8624,14 +10328,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8670,7 +10374,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8680,7 +10413,7 @@ export class TablesDB { * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8688,7 +10421,7 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8697,7 +10430,7 @@ export class TablesDB { * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8706,7 +10439,7 @@ export class TablesDB { databaseId: string, tableId: string, rows: object[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; upsertRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8714,16 +10447,16 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object[]?, string?] + ...rest: [string?, object[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8735,14 +10468,14 @@ export class TablesDB { databaseId: string; tableId: string; rows: object[]; - transactionId?: string; + transactionId?: string | null; }; } 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 | null, }; } @@ -8781,7 +10514,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -8791,7 +10553,7 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {object} params.data - Row data as JSON object. Include only column 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. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} */ @@ -8800,7 +10562,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }): Promise<Models.RowList<Row>>; /** * 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. @@ -8809,7 +10571,7 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {object} data - Row data as JSON object. Include only column 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. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Models.RowList<Row>>} * @deprecated Use the object parameter style method for a better developer experience. @@ -8819,7 +10581,7 @@ export class TablesDB { tableId: string, data?: object, queries?: string[], - transactionId?: string, + transactionId?: string | null, ): Promise<Models.RowList<Row>>; updateRows<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -8828,17 +10590,17 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; } | string, - ...rest: [string?, object?, string[]?, string?] + ...rest: [string?, object?, string[]?, (string | null)?] ): Promise<Models.RowList<Row>> { let params: { databaseId: string; tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; if ( @@ -8851,7 +10613,7 @@ export class TablesDB { tableId: string; data?: object; queries?: string[]; - transactionId?: string; + transactionId?: string | null; }; } else { params = { @@ -8859,7 +10621,7 @@ export class TablesDB { 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 | null, }; } @@ -8899,7 +10661,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9005,7 +10796,36 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'rowList', + models: { + rowList: { + defaults: { + total: 0, + rows: [], + }, + properties: { + rows: { + items: 'row', + }, + }, + }, + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9123,7 +10943,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9133,8 +10971,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9145,8 +10983,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * 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. @@ -9155,8 +10993,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include all required columns of the row 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9168,8 +11006,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; upsertRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9181,8 +11019,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9191,8 +11029,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9202,8 +11040,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9219,8 +11057,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9231,8 +11069,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9277,7 +11115,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9287,8 +11143,8 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} params.data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} 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 | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9299,8 +11155,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }): Promise<Row>; /** * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -9309,8 +11165,8 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} rowId - Row ID. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>} data - Row data as JSON object. Include only columns 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. + * @param {string[] | null} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9322,8 +11178,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions?: string[], - transactionId?: string, + permissions?: string[] | null, + transactionId?: string | null, ): Promise<Row>; updateRow<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9335,8 +11191,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; } | string, ...rest: [ @@ -9345,8 +11201,8 @@ export class TablesDB { (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>)?, - string[]?, - string?, + (string[] | null)?, + (string | null)?, ] ): Promise<Row> { let params: { @@ -9356,8 +11212,8 @@ export class TablesDB { data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; if ( @@ -9373,8 +11229,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>; - permissions?: string[]; - transactionId?: string; + permissions?: string[] | null; + transactionId?: string | null; }; } else { params = { @@ -9385,8 +11241,8 @@ export class TablesDB { ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Partial<Omit<Row, keyof Models.Row>>, - permissions: rest[3] as string[], - transactionId: rest[4] as string, + permissions: rest[3] as string[] | null, + transactionId: rest[4] as string | null, }; } @@ -9431,7 +11287,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9549,8 +11423,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9560,8 +11434,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Decrement a specific column of a row by a given value. @@ -9571,8 +11445,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} min - Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9583,8 +11457,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - min?: number, - transactionId?: string, + min?: number | null, + transactionId?: string | null, ): Promise<Row>; decrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9594,11 +11468,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9606,8 +11487,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; if ( @@ -9621,8 +11502,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - min?: number; - transactionId?: string; + min?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9631,8 +11512,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - min: rest[4] as number, - transactionId: rest[5] as string, + min: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9683,7 +11564,25 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -9694,8 +11593,8 @@ export class TablesDB { * @param {string} params.rowId - Row ID. * @param {string} params.column - Column key. * @param {number} params.value - Value to increment the column by. The value must be a number. - * @param {number} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} params.transactionId - Transaction ID for staging the operation. + * @param {number | null} params.max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ @@ -9705,8 +11604,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }): Promise<Row>; /** * Increment a specific column of a row by a given value. @@ -9716,8 +11615,8 @@ export class TablesDB { * @param {string} rowId - Row ID. * @param {string} column - Column key. * @param {number} value - Value to increment the column by. The value must be a number. - * @param {number} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. - * @param {string} transactionId - Transaction ID for staging the operation. + * @param {number | null} max - Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param {string | null} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. @@ -9728,8 +11627,8 @@ export class TablesDB { rowId: string, column: string, value?: number, - max?: number, - transactionId?: string, + max?: number | null, + transactionId?: string | null, ): Promise<Row>; incrementRowColumn<Row extends Models.Row = Models.DefaultRow>( paramsOrFirst: @@ -9739,11 +11638,18 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; } | string, - ...rest: [string?, string?, string?, number?, number?, string?] + ...rest: [ + string?, + string?, + string?, + number?, + (number | null)?, + (string | null)?, + ] ): Promise<Row> { let params: { databaseId: string; @@ -9751,8 +11657,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; if ( @@ -9766,8 +11672,8 @@ export class TablesDB { rowId: string; column: string; value?: number; - max?: number; - transactionId?: string; + max?: number | null; + transactionId?: string | null; }; } else { params = { @@ -9776,8 +11682,8 @@ export class TablesDB { rowId: rest[1] as string, column: rest[2] as string, value: rest[3] as number, - max: rest[4] as number, - transactionId: rest[5] as string, + max: rest[4] as number | null, + transactionId: rest[5] as string | null, }; } @@ -9828,6 +11734,24 @@ export class TablesDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'row', + models: { + row: { + defaults: { + $id: '', + $sequence: '', + $tableId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/teams.ts b/src/services/teams.ts index 821acb7..8e9f2ae 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Teams { @@ -86,7 +91,34 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'teamList', + models: { + teamList: { + defaults: { + total: 0, + teams: [], + }, + properties: { + teams: { + items: 'team', + }, + }, + }, + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -173,7 +205,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -230,7 +278,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -304,7 +368,23 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'team', + models: { + team: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + total: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -437,7 +517,38 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallationList', + models: { + appInstallationList: { + defaults: { + total: 0, + installations: [], + }, + properties: { + installations: { + items: 'appInstallation', + }, + }, + }, + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -527,7 +638,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -601,7 +732,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -609,21 +760,21 @@ export class Teams { * * @param {string} params.teamId - Team ID. * @param {string} params.installationId - Installation unique ID. - * @param {string} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} params.authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} */ updateInstallation(params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }): Promise<Models.AppInstallation>; /** * 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. * * @param {string} teamId - Team ID. * @param {string} installationId - Installation unique ID. - * @param {string} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + * @param {string | null} authorizationDetails - Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. * @throws {AppwriteException} * @returns {Promise<Models.AppInstallation>} * @deprecated Use the object parameter style method for a better developer experience. @@ -631,22 +782,22 @@ export class Teams { updateInstallation( teamId: string, installationId: string, - authorizationDetails?: string, + authorizationDetails?: string | null, ): Promise<Models.AppInstallation>; updateInstallation( paramsOrFirst: | { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; } | string, - ...rest: [string?, string?] + ...rest: [string?, (string | null)?] ): Promise<Models.AppInstallation> { let params: { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; if ( @@ -657,13 +808,13 @@ export class Teams { params = (paramsOrFirst || {}) as { teamId: string; installationId: string; - authorizationDetails?: string; + authorizationDetails?: string | null; }; } else { params = { teamId: paramsOrFirst as string, installationId: rest[0] as string, - authorizationDetails: rest[1] as string, + authorizationDetails: rest[1] as string | null, }; } @@ -696,7 +847,27 @@ export class Teams { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'appInstallation', + models: { + appInstallation: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + appId: '', + teamId: '', + scopes: [], + authorizationDetails: [], + createdById: '', + createdByName: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -870,7 +1041,44 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -890,6 +1098,7 @@ export class Teams { * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} params.url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.name - Name of the new team member. Max length: 128 chars. + * @param {string} params.membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} */ @@ -901,6 +1110,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }): Promise<Models.Membership>; /** * 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. @@ -919,6 +1129,7 @@ export class Teams { * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param {string} url - URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} name - Name of the new team member. Max length: 128 chars. + * @param {string} membershipId - Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @throws {AppwriteException} * @returns {Promise<Models.Membership>} * @deprecated Use the object parameter style method for a better developer experience. @@ -931,6 +1142,7 @@ export class Teams { phone?: string, url?: string, name?: string, + membershipId?: string, ): Promise<Models.Membership>; createMembership( paramsOrFirst: @@ -942,9 +1154,18 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; } | string, - ...rest: [string[]?, string?, string?, string?, string?, string?] + ...rest: [ + string[]?, + string?, + string?, + string?, + string?, + string?, + string?, + ] ): Promise<Models.Membership> { let params: { teamId: string; @@ -954,6 +1175,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; if ( @@ -969,6 +1191,7 @@ export class Teams { phone?: string; url?: string; name?: string; + membershipId?: string; }; } else { params = { @@ -979,6 +1202,7 @@ export class Teams { phone: rest[3] as string, url: rest[4] as string, name: rest[5] as string, + membershipId: rest[6] as string, }; } @@ -989,6 +1213,7 @@ export class Teams { const phone = params.phone; const url = params.url; const name = params.name; + const membershipId = params.membershipId; if (typeof teamId === 'undefined' || teamId === '') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -1018,6 +1243,9 @@ export class Teams { if (typeof name !== 'undefined') { apiPayload['name'] = name; } + if (typeof membershipId !== 'undefined') { + apiPayload['membershipId'] = membershipId; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1026,7 +1254,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1100,7 +1354,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1191,7 +1471,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1382,7 +1688,33 @@ export class Teams { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membership', + models: { + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/tokens.ts b/src/services/tokens.ts index 796ccf9..580a3d4 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Tokens { @@ -108,7 +113,36 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceTokenList', + models: { + resourceTokenList: { + defaults: { + total: 0, + tokens: [], + }, + properties: { + tokens: { + items: 'resourceToken', + }, + }, + }, + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -116,21 +150,21 @@ export class Tokens { * * @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 unique ID. - * @param {string} params.expire - Token expiry date + * @param {string | null} params.expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ createFileToken(params: { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. * * @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 unique ID. - * @param {string} expire - Token expiry date + * @param {string | null} expire - Token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. @@ -138,14 +172,19 @@ export class Tokens { createFileToken( bucketId: string, fileId: string, - expire?: string, + expire?: string | null, ): Promise<Models.ResourceToken>; createFileToken( paramsOrFirst: - { bucketId: string; fileId: string; expire?: string } | string, - ...rest: [string?, string?] + | { bucketId: string; fileId: string; expire?: string | null } + | string, + ...rest: [string?, (string | null)?] ): Promise<Models.ResourceToken> { - let params: { bucketId: string; fileId: string; expire?: string }; + let params: { + bucketId: string; + fileId: string; + expire?: string | null; + }; if ( paramsOrFirst && @@ -155,13 +194,13 @@ export class Tokens { params = (paramsOrFirst || {}) as { bucketId: string; fileId: string; - expire?: string; + expire?: string | null; }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - expire: rest[1] as string, + expire: rest[1] as string | null, }; } @@ -191,7 +230,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -246,36 +303,57 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} params.tokenId - Token unique ID. - * @param {string} params.expire - File token expiry date + * @param {string | null} params.expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} */ update(params: { tokenId: string; - expire?: string; + expire?: string | null; }): Promise<Models.ResourceToken>; /** * Update a token by its unique ID. Use this endpoint to update a token's expiry date. * * @param {string} tokenId - Token unique ID. - * @param {string} expire - File token expiry date + * @param {string | null} expire - File token expiry date * @throws {AppwriteException} * @returns {Promise<Models.ResourceToken>} * @deprecated Use the object parameter style method for a better developer experience. */ - update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; update( - paramsOrFirst: { tokenId: string; expire?: string } | string, - ...rest: [string?] + tokenId: string, + expire?: string | null, + ): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string; expire?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.ResourceToken> { - let params: { tokenId: string; expire?: string }; + let params: { tokenId: string; expire?: string | null }; if ( paramsOrFirst && @@ -284,12 +362,12 @@ export class Tokens { ) { params = (paramsOrFirst || {}) as { tokenId: string; - expire?: string; + expire?: string | null; }; } else { params = { tokenId: paramsOrFirst as string, - expire: rest[0] as string, + expire: rest[0] as string | null, }; } @@ -316,7 +394,25 @@ export class Tokens { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'resourceToken', + models: { + resourceToken: { + defaults: { + $id: '', + $createdAt: '', + resourceId: '', + resourceType: '', + expire: '', + secret: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** diff --git a/src/services/users.ts b/src/services/users.ts index 0210046..77a515b 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { PasswordHash } from '../enums/password-hash'; @@ -89,16 +94,70 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'userList', + models: { + userList: { + defaults: { + total: 0, + users: [], + }, + properties: { + users: { + items: 'user', + }, + }, + }, + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** * Create a new user. * * @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. - * @param {string} params.email - User email. - * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string | null} params.email - User email. + * @param {string | null} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} params.password - Plain text user password. Must be at least 8 chars. * @param {string} params.name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -107,18 +166,18 @@ export class Users { Preferences extends Models.Preferences = Models.DefaultPreferences, >(params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }): Promise<Models.User<Preferences>>; /** * Create a new user. * * @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. - * @param {string} email - User email. - * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string | null} email - User email. + * @param {string | null} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string | null} password - Plain text user password. Must be at least 8 chars. * @param {string} name - User name. Max length: 128 chars. * @throws {AppwriteException} * @returns {Promise<Models.User<Preferences>>} @@ -126,28 +185,28 @@ export class Users { */ create<Preferences extends Models.Preferences = Models.DefaultPreferences>( userId: string, - email?: string, - phone?: string, - password?: string, + email?: string | null, + phone?: string | null, + password?: string | null, name?: string, ): Promise<Models.User<Preferences>>; create<Preferences extends Models.Preferences = Models.DefaultPreferences>( paramsOrFirst: | { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; } | string, - ...rest: [string?, string?, string?, string?] + ...rest: [(string | null)?, (string | null)?, (string | null)?, string?] ): Promise<Models.User<Preferences>> { let params: { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; @@ -158,17 +217,17 @@ export class Users { ) { params = (paramsOrFirst || {}) as { userId: string; - email?: string; - phone?: string; - password?: string; + email?: string | null; + phone?: string | null; + password?: string | null; name?: string; }; } else { params = { userId: paramsOrFirst as string, - email: rest[0] as string, - phone: rest[1] as string, - password: rest[2] as string, + email: rest[0] as string | null, + phone: rest[1] as string | null, + password: rest[2] as string | null, name: rest[3] as string, }; } @@ -206,7 +265,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -318,7 +420,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -430,7 +575,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -509,7 +697,40 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'identityList', + models: { + identityList: { + defaults: { + total: 0, + identities: [], + }, + properties: { + identities: { + items: 'identity', + }, + }, + }, + identity: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + provider: '', + providerUid: '', + providerEmail: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + providerIdToken: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +898,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -789,7 +1053,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1000,7 +1307,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1168,7 +1518,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1297,7 +1690,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1354,7 +1790,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1480,7 +1959,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1561,7 +2083,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1643,7 +2208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'jwt', + models: { + jwt: { + defaults: { + jwt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1724,7 +2301,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1826,7 +2446,44 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'membershipList', + models: { + membershipList: { + defaults: { + total: 0, + memberships: [], + }, + properties: { + memberships: { + items: 'membership', + }, + }, + }, + membership: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + userName: '', + userEmail: '', + userPhone: '', + teamId: '', + teamName: '', + invited: '', + joined: '', + confirm: false, + mfa: false, + userAccessedAt: '', + roles: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1901,7 +2558,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1975,7 +2675,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2187,7 +2930,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaChallengeSecret', + models: { + mfaChallengeSecret: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + expire: '', + code: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2241,7 +3000,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2294,7 +3069,23 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaFactors', + models: { + mfaFactors: { + defaults: { + totp: false, + phone: false, + email: false, + recoveryCode: false, + custom: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2350,7 +3141,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2405,7 +3208,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3277,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2518,7 +3345,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2575,7 +3414,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3482,19 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'mfaRecoveryCodes', + models: { + mfaRecoveryCodes: { + defaults: { + recoveryCodes: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2705,7 +3568,410 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} params.userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + */ + listPasskeys(params: { + userId: string; + queries?: string[]; + total?: boolean; + }): Promise<Models.PasskeyList>; + /** + * Get the list of verified passkeys registered by a user. + * + * @param {string} userId - User 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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PasskeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPasskeys( + userId: string, + queries?: string[], + total?: boolean, + ): Promise<Models.PasskeyList>; + listPasskeys( + paramsOrFirst: + { userId: string; queries?: string[]; total?: boolean } | string, + ...rest: [string[]?, boolean?] + ): Promise<Models.PasskeyList> { + 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, + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + const apiPath = '/users/{userId}/passkeys'.replace( + '{userId}', + encodeURIComponent(String(userId)), + ); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkeyList', + models: { + passkeyList: { + defaults: { + total: 0, + passkeys: [], + }, + properties: { + passkeys: { + items: 'passkey', + }, + }, + }, + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + getPasskey(params: { + userId: string; + passkeyId: string; + }): Promise<Models.Passkey>; + /** + * Get a verified passkey of a user by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPasskey(userId: string, passkeyId: string): Promise<Models.Passkey>; + getPasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Rename a passkey of a user. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @param {string} params.name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + */ + updatePasskey(params: { + userId: string; + passkeyId: string; + name: string; + }): Promise<Models.Passkey>; + /** + * Rename a passkey of a user. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @param {string} name - Passkey name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Passkey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasskey( + userId: string, + passkeyId: string, + name: string, + ): Promise<Models.Passkey>; + updatePasskey( + paramsOrFirst: + { userId: string; passkeyId: string; name: string } | string, + ...rest: [string?, string?] + ): Promise<Models.Passkey> { + let params: { userId: string; passkeyId: string; name: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + name: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + name: rest[1] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + const name = params.name; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'passkey', + models: { + passkey: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + accessedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} params.userId - User ID. + * @param {string} params.passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePasskey(params: { userId: string; passkeyId: string }): Promise<{}>; + /** + * Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. + * + * @param {string} userId - User ID. + * @param {string} passkeyId - Passkey ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePasskey(userId: string, passkeyId: string): Promise<{}>; + deletePasskey( + paramsOrFirst: { userId: string; passkeyId: string } | string, + ...rest: [string?] + ): Promise<{}> { + let params: { userId: string; passkeyId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + userId: string; + passkeyId: string; + }; + } else { + params = { + userId: paramsOrFirst as string, + passkeyId: rest[0] as string, + }; + } + + const userId = params.userId; + const passkeyId = params.passkeyId; + if (typeof userId === 'undefined' || userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof passkeyId === 'undefined' || passkeyId === '') { + throw new AppwriteException( + 'Missing required parameter: "passkeyId"', + ); + } + const apiPath = '/users/{userId}/passkeys/{passkeyId}' + .replace('{userId}', encodeURIComponent(String(userId))) + .replace('{passkeyId}', encodeURIComponent(String(passkeyId))); + 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); } /** @@ -2784,7 +4050,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2861,7 +4170,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3056,7 +4408,58 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'sessionList', + models: { + sessionList: { + defaults: { + total: 0, + sessions: [], + }, + properties: { + sessions: { + items: 'session', + }, + }, + }, + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3114,7 +4517,47 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'session', + models: { + session: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + userId: '', + expire: '', + provider: '', + providerUid: '', + providerAccessToken: '', + providerAccessTokenExpiry: '', + providerRefreshToken: '', + ip: '', + osCode: '', + osName: '', + osVersion: '', + clientType: '', + clientCode: '', + clientName: '', + clientVersion: '', + clientEngine: '', + clientEngineVersion: '', + deviceName: '', + deviceBrand: '', + deviceModel: '', + countryCode: '', + countryName: '', + current: false, + factors: [], + secret: '', + mfaUpdatedAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3309,7 +4752,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3390,7 +4876,37 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'targetList', + models: { + targetList: { + defaults: { + total: 0, + targets: [], + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3532,7 +5048,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3600,7 +5135,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3716,7 +5270,26 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'target', + models: { + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3866,7 +5439,24 @@ export class Users { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'token', + models: { + token: { + defaults: { + $id: '', + $createdAt: '', + userId: '', + secret: '', + expire: '', + phrase: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3948,7 +5538,50 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -4030,6 +5663,49 @@ export class Users { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'user', + models: { + user: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + registration: '', + status: true, + labels: [], + passwordUpdate: '', + email: '', + phone: '', + emailVerification: false, + phoneVerification: false, + mfa: false, + targets: [], + accessedAt: '', + }, + properties: { + targets: { + items: 'target', + }, + }, + }, + target: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + userId: '', + providerType: '', + identifier: '', + expired: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index 55871ee..d2f0c5d 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; @@ -72,7 +77,69 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseList', + models: { + databaseList: { + defaults: { + total: 0, + databases: [], + }, + properties: { + databases: { + items: 'database', + }, + }, + }, + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -84,7 +151,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} */ @@ -94,7 +161,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }): Promise<Models.Database>; /** * Create a new Database. @@ -105,7 +172,7 @@ export class VectorsDB { * @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. + * @param {string | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -116,7 +183,7 @@ export class VectorsDB { enabled?: boolean, specification?: string, replicas?: number, - syncMode?: string, + syncMode?: string | null, ): Promise<Models.Database>; create( paramsOrFirst: @@ -126,10 +193,10 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [string?, boolean?, string?, number?, (string | null)?] ): Promise<Models.Database> { let params: { databaseId: string; @@ -137,7 +204,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; if ( @@ -151,7 +218,7 @@ export class VectorsDB { enabled?: boolean; specification?: string; replicas?: number; - syncMode?: string; + syncMode?: string | null; }; } else { params = { @@ -160,7 +227,7 @@ export class VectorsDB { 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 | null, }; } @@ -206,7 +273,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -225,7 +343,42 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseSpecificationList', + models: { + dedicatedDatabaseSpecificationList: { + defaults: { + specifications: [], + total: 0, + }, + properties: { + specifications: { + items: 'dedicatedDatabaseSpecification', + }, + }, + }, + dedicatedDatabaseSpecification: { + defaults: { + slug: '', + name: '', + price: 0, + storageOverageRate: 0, + bandwidthOverageRate: 0, + replicaRate: 0, + pitrRate: 0, + cpu: 0, + memory: 0, + maxConnections: 0, + includedStorage: 0, + includedBandwidth: 0, + enabled: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -293,7 +446,35 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transactionList', + models: { + transactionList: { + defaults: { + total: 0, + transactions: [], + }, + properties: { + transactions: { + items: 'transaction', + }, + }, + }, + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -345,7 +526,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -402,7 +600,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -491,7 +706,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -622,7 +854,24 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'transaction', + models: { + transaction: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + status: 'pending', + operations: 0, + expiresAt: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -677,7 +926,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -686,9 +986,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} */ @@ -696,9 +996,9 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }): Promise<Models.Database>; /** * Update a database by its unique ID. @@ -706,9 +1006,9 @@ export class VectorsDB { * @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. + * @param {string | null} 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 | null} 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 | null} 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<Models.Database>} * @deprecated Use the object parameter style method for a better developer experience. @@ -717,9 +1017,9 @@ export class VectorsDB { databaseId: string, name: string, enabled?: boolean, - specification?: string, - replicas?: number, - syncMode?: string, + specification?: string | null, + replicas?: number | null, + syncMode?: string | null, ): Promise<Models.Database>; update( paramsOrFirst: @@ -727,20 +1027,26 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; } | string, - ...rest: [string?, boolean?, string?, number?, string?] + ...rest: [ + string?, + boolean?, + (string | null)?, + (number | null)?, + (string | null)?, + ] ): Promise<Models.Database> { let params: { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; if ( @@ -752,18 +1058,18 @@ export class VectorsDB { databaseId: string; name: string; enabled?: boolean; - specification?: string; - replicas?: number; - syncMode?: string; + specification?: string | null; + replicas?: number | null; + syncMode?: string | null; }; } 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, + specification: rest[2] as string | null, + replicas: rest[3] as number | null, + syncMode: rest[4] as string | null, }; } @@ -809,7 +1115,58 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'database', + models: { + database: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + enabled: true, + type: 'legacy', + }, + properties: { + policies: { + items: 'backupPolicy', + }, + archives: { + items: 'backupArchive', + }, + }, + }, + backupPolicy: { + defaults: { + $id: '', + name: '', + $createdAt: '', + $updatedAt: '', + services: [], + resources: [], + retention: 1, + schedule: '0 * * * *', + type: 'full', + enabled: false, + }, + }, + backupArchive: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + policyId: '', + status: '', + migrationId: '', + services: [], + resources: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -967,7 +1324,59 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollectionList', + models: { + vectorsdbCollectionList: { + defaults: { + total: 0, + collections: [], + }, + properties: { + collections: { + items: 'vectorsdbCollection', + }, + }, + }, + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1121,7 +1530,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1197,7 +1647,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1209,7 +1700,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} */ @@ -1220,7 +1711,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }): Promise<Models.VectorsdbCollection>; /** * Update a collection by its unique ID. @@ -1231,7 +1722,7 @@ export class VectorsDB { * @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. + * @param {boolean | null} 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<Models.VectorsdbCollection>} * @deprecated Use the object parameter style method for a better developer experience. @@ -1243,7 +1734,7 @@ export class VectorsDB { dimension?: number, permissions?: string[], documentSecurity?: boolean, - enabled?: boolean, + enabled?: boolean | null, ): Promise<Models.VectorsdbCollection>; updateCollection( paramsOrFirst: @@ -1254,10 +1745,17 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; } | string, - ...rest: [string?, string?, number?, string[]?, boolean?, boolean?] + ...rest: [ + string?, + string?, + number?, + string[]?, + boolean?, + (boolean | null)?, + ] ): Promise<Models.VectorsdbCollection> { let params: { databaseId: string; @@ -1266,7 +1764,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; if ( @@ -1281,7 +1779,7 @@ export class VectorsDB { dimension?: number; permissions?: string[]; documentSecurity?: boolean; - enabled?: boolean; + enabled?: boolean | null; }; } else { params = { @@ -1291,7 +1789,7 @@ export class VectorsDB { dimension: rest[2] as number, permissions: rest[3] as string[], documentSecurity: rest[4] as boolean, - enabled: rest[5] as boolean, + enabled: rest[5] as boolean | null, }; } @@ -1345,7 +1843,48 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'vectorsdbCollection', + models: { + vectorsdbCollection: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + databaseId: '', + name: '', + enabled: true, + documentSecurity: false, + attributes: [], + indexes: [], + bytesMax: 0, + bytesUsed: 0, + dimension: 0, + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1554,7 +2093,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1723,7 +2291,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1840,7 +2426,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -1959,7 +2574,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2083,7 +2727,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2195,7 +2868,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('delete', uri, apiHeaders, apiPayload); + const request = this.client.call('delete', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2333,7 +3035,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'documentList', + models: { + documentList: { + defaults: { + total: 0, + documents: [], + }, + properties: { + documents: { + items: 'document', + }, + }, + }, + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2462,7 +3193,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2631,7 +3380,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -2800,7 +3567,25 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'document', + models: { + document: { + defaults: { + $id: '', + $sequence: '', + $collectionId: '', + $databaseId: '', + $createdAt: '', + $updatedAt: '', + $permissions: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3025,7 +3810,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'indexList', + models: { + indexList: { + defaults: { + total: 0, + indexes: [], + }, + properties: { + indexes: { + items: 'index', + }, + }, + }, + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3191,7 +4006,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3280,7 +4114,26 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'index', + models: { + index: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + key: '', + type: '', + error: '', + attributes: [], + lengths: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3377,33 +4230,33 @@ export class VectorsDB { * 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. + * @param {string | null} params.targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} */ createFailover(params: { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }): Promise<Models.DedicatedDatabase>; /** * 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. + * @param {string | null} targetReplicaId - Target replica ID to promote. If not specified, the healthiest replica is selected. * @throws {AppwriteException} * @returns {Promise<Models.DedicatedDatabase>} * @deprecated Use the object parameter style method for a better developer experience. */ createFailover( databaseId: string, - targetReplicaId?: string, + targetReplicaId?: string | null, ): Promise<Models.DedicatedDatabase>; createFailover( paramsOrFirst: - { databaseId: string; targetReplicaId?: string } | string, - ...rest: [string?] + { databaseId: string; targetReplicaId?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.DedicatedDatabase> { - let params: { databaseId: string; targetReplicaId?: string }; + let params: { databaseId: string; targetReplicaId?: string | null }; if ( paramsOrFirst && @@ -3412,12 +4265,12 @@ export class VectorsDB { ) { params = (paramsOrFirst || {}) as { databaseId: string; - targetReplicaId?: string; + targetReplicaId?: string | null; }; } else { params = { databaseId: paramsOrFirst as string, - targetReplicaId: rest[0] as string, + targetReplicaId: rest[0] as string | null, }; } @@ -3444,7 +4297,63 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabase', + models: { + dedicatedDatabase: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + projectId: '', + name: '', + version: '', + specification: '', + backend: '', + hostname: '', + connectionUser: '', + connectionPassword: '', + connectionString: '', + ssl: false, + status: 'provisioning', + containerStatus: '', + lifecycleState: '', + idleTimeoutMinutes: 15, + cpu: 500, + memory: 512, + storage: 10, + storageStatus: 'idle', + storageTargetGb: 0, + storageClass: 'ssd', + storageMaxGb: 0, + nodePool: '', + replicas: 0, + syncMode: '', + networkMaxConnections: 100, + networkIdleTimeoutSeconds: 900, + networkIPAllowlist: [], + backupEnabled: true, + pitr: true, + pitrRetentionDays: 7, + storageAutoscaling: true, + storageAutoscalingThresholdPercent: 85, + storageAutoscalingMaxGb: 0, + maintenanceWindowDay: 'sun', + maintenanceWindowHourUtc: 3, + metricsEnabled: false, + sqlApiEnabled: true, + sqlApiAllowedStatements: ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + sqlApiMaxRows: 10000, + sqlApiMaxBytes: 10485760, + sqlApiTimeoutSeconds: 30, + error: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3548,7 +4457,37 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseOperationList', + models: { + dedicatedDatabaseOperationList: { + defaults: { + total: 0, + operations: [], + }, + properties: { + operations: { + items: 'dedicatedDatabaseOperation', + }, + }, + }, + dedicatedDatabaseOperation: { + defaults: { + $id: '', + $createdAt: '', + databaseId: '', + type: '', + status: '', + attempts: 0, + errorCode: '', + errorMessage: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3605,7 +4544,36 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'dedicatedDatabaseReplicas', + models: { + dedicatedDatabaseReplicas: { + defaults: { + replicas: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + members: [], + }, + properties: { + members: { + items: 'dedicatedDatabaseMember', + }, + }, + }, + dedicatedDatabaseMember: { + defaults: { + $id: '', + role: 'unknown', + status: '', + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -3660,6 +4628,51 @@ export class VectorsDB { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'databaseStatus', + models: { + databaseStatus: { + defaults: { + health: 'unknown', + ready: false, + engine: 'postgresql', + version: '', + uptime: 0, + syncMode: 'async', + syncDegraded: false, + syncAcknowledgements: 0, + syncStandbyCount: 0, + replicas: [], + volumes: [], + }, + properties: { + replicas: { + items: 'databaseStatusReplica', + }, + volumes: { + items: 'databaseStatusVolume', + }, + }, + }, + databaseStatusReplica: { + defaults: { + index: 0, + role: 'unknown', + healthy: false, + }, + }, + databaseStatusVolume: { + defaults: { + path: '', + usedPercent: '0%', + available: '0GB', + mounted: false, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/services/waf.ts b/src/services/waf.ts new file mode 100644 index 0000000..41404b9 --- /dev/null +++ b/src/services/waf.ts @@ -0,0 +1,2415 @@ +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; +import type { Models } from '../models'; + +export class Waf { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List WAF rules for the current project. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + */ + listRules(params?: { + queries?: string[]; + search?: string; + total?: boolean; + }): Promise<Models.WafRuleList>; + /** + * List WAF rules for the current project. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules( + queries?: string[], + search?: string, + total?: boolean, + ): Promise<Models.WafRuleList>; + listRules( + paramsOrFirst?: + { queries?: string[]; search?: string; total?: boolean } | string[], + ...rest: [string?, boolean?] + ): Promise<Models.WafRuleList> { + let params: { queries?: string[]; search?: string; total?: boolean }; + + if ( + (typeof paramsOrFirst === 'undefined' && rest.length === 0) || + (paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst)) + ) { + params = (paramsOrFirst || {}) as { + queries?: string[]; + search?: string; + total?: boolean; + }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean, + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + const apiPath = '/waf/rules'; + const apiPayload: Payload = {}; + if (typeof queries !== 'undefined') { + apiPayload['queries'] = queries; + } + if (typeof search !== 'undefined') { + apiPayload['search'] = search; + } + if (typeof total !== 'undefined') { + apiPayload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleList', + models: { + wafRuleList: { + defaults: { + total: 0, + rules: [], + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + createBypassRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleBypass>; + /** + * Create a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Leave empty for the API resource type. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBypassRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleBypass>; + createBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/bypass'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + */ + updateBypassRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleBypass>; + /** + * Update a bypass WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBypassRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleBypass>; + updateBypassRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleBypass> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/bypass/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleBypass', + models: { + wafRuleBypass: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.challengeType - Challenge type enforced by the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + createChallengeRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }): Promise<Models.WafRuleChallenge>; + /** + * Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} challengeType - Challenge type enforced by the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createChallengeRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + challengeType?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + difficulty?: number, + ttl?: number, + ): Promise<Models.WafRuleChallenge>; + createChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + string?, + number?, + boolean?, + string[]?, + number?, + number?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + challengeType?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + difficulty?: number; + ttl?: number; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + challengeType: rest[4] as string, + priority: rest[5] as number, + enabled: rest[6] as boolean, + conditions: rest[7] as string[], + difficulty: rest[8] as number, + ttl: rest[9] as number, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/challenge'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.challengeType - Challenge type enforced by the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} params.difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} params.ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + */ + updateChallengeRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }): Promise<Models.WafRuleChallenge>; + /** + * Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to tune the client-side proof-of-work cost, and `ttl` to control how long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} challengeType - Challenge type enforced by the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @param {number | null} difficulty - Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + * @param {number | null} ttl - How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateChallengeRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + challengeType?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + difficulty?: number | null, + ttl?: number | null, + ): Promise<Models.WafRuleChallenge>; + updateChallengeRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + (number | null)?, + (number | null)?, + ] + ): Promise<Models.WafRuleChallenge> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + challengeType?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + difficulty?: number | null; + ttl?: number | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + challengeType: rest[4] as string | null, + priority: rest[5] as number | null, + enabled: rest[6] as boolean | null, + conditions: rest[7] as string[] | null, + difficulty: rest[8] as number | null, + ttl: rest[9] as number | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const challengeType = params.challengeType; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + const difficulty = params.difficulty; + const ttl = params.ttl; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/challenge/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof challengeType !== 'undefined') { + apiPayload['challengeType'] = challengeType; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + if (typeof difficulty !== 'undefined') { + apiPayload['difficulty'] = difficulty; + } + if (typeof ttl !== 'undefined') { + apiPayload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleChallenge', + models: { + wafRuleChallenge: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + createDenyRule(params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleDeny>; + /** + * Create a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDenyRule( + ruleId: string, + resourceType: string, + name: string, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleDeny>; + createDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + resourceId: rest[2] as string | null, + description: rest[3] as string, + priority: rest[4] as number, + enabled: rest[5] as boolean, + conditions: rest[6] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + const apiPath = '/waf/rules/deny'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + */ + updateDenyRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleDeny>; + /** + * Update a deny WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleDeny>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleDeny>; + updateDenyRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleDeny> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + priority: rest[4] as number | null, + enabled: rest[5] as boolean | null, + conditions: rest[6] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/deny/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleDeny', + models: { + wafRuleDeny: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {number} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {string} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} params.strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + createRateLimitRule(params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRateLimit>; + /** + * Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {number} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number} interval - Interval in seconds used for rate limiting. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {string} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {string} strategy - Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRateLimitRule( + ruleId: string, + resourceType: string, + name: string, + limit: number, + interval: number, + resourceId?: string | null, + description?: string, + key?: string, + strategy?: string, + maxBucketSize?: number | null, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRateLimit>; + createRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + number?, + number?, + (string | null)?, + string?, + string?, + string?, + (number | null)?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + limit: number; + interval: number; + resourceId?: string | null; + description?: string; + key?: string; + strategy?: string; + maxBucketSize?: number | null; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + limit: rest[2] as number, + interval: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + key: rest[6] as string, + strategy: rest[7] as string, + maxBucketSize: rest[8] as number | null, + priority: rest[9] as number, + enabled: rest[10] as boolean, + conditions: rest[11] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const limit = params.limit; + const interval = params.interval; + const resourceId = params.resourceId; + const description = params.description; + const key = params.key; + const strategy = params.strategy; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof limit === 'undefined') { + throw new AppwriteException('Missing required parameter: "limit"'); + } + if (typeof interval === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "interval"', + ); + } + const apiPath = '/waf/rules/rate-limit'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof strategy !== 'undefined') { + apiPayload['strategy'] = strategy; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {number | null} params.limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} params.interval - Interval in seconds used for rate limiting. + * @param {string | null} params.key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} params.maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + */ + updateRateLimitRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRateLimit>; + /** + * Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits per client IP, while `userId` limits per authenticated user (requests without an authenticated user skip `userId` rules). Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {number | null} limit - Maximum number of matching requests allowed in the configured interval. + * @param {number | null} interval - Interval in seconds used for rate limiting. + * @param {string | null} key - Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + * @param {number | null} maxBucketSize - Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRateLimit>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRateLimitRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + limit?: number | null, + interval?: number | null, + key?: string | null, + maxBucketSize?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRateLimit>; + updateRateLimitRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRateLimit> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + limit?: number | null; + interval?: number | null; + key?: string | null; + maxBucketSize?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + limit: rest[4] as number | null, + interval: rest[5] as number | null, + key: rest[6] as string | null, + maxBucketSize: rest[7] as number | null, + priority: rest[8] as number | null, + enabled: rest[9] as boolean | null, + conditions: rest[10] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const limit = params.limit; + const interval = params.interval; + const key = params.key; + const maxBucketSize = params.maxBucketSize; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/rate-limit/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof limit !== 'undefined') { + apiPayload['limit'] = limit; + } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } + if (typeof key !== 'undefined') { + apiPayload['key'] = key; + } + if (typeof maxBucketSize !== 'undefined') { + apiPayload['maxBucketSize'] = maxBucketSize; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRateLimit', + models: { + wafRuleRateLimit: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + limit: 100, + interval: 3600, + key: 'ip', + strategy: 'fixedWindow', + maxBucketSize: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} params.resourceType - Resource type the rule applies to. + * @param {string} params.name - Rule name. + * @param {string} params.location - Location used for redirect responses. + * @param {number} params.statusCode - Integer status code used for redirect responses. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string} params.description - Optional description for the rule. + * @param {number} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} params.enabled - Set to false to create the rule in a disabled state. + * @param {string[]} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + createRedirectRule(params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }): Promise<Models.WafRuleRedirect>; + /** + * Create a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + * @param {string} resourceType - Resource type the rule applies to. + * @param {string} name - Rule name. + * @param {string} location - Location used for redirect responses. + * @param {number} statusCode - Integer status code used for redirect responses. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string} description - Optional description for the rule. + * @param {number} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean} enabled - Set to false to create the rule in a disabled state. + * @param {string[]} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule( + ruleId: string, + resourceType: string, + name: string, + location: string, + statusCode: number, + resourceId?: string | null, + description?: string, + priority?: number, + enabled?: boolean, + conditions?: string[], + ): Promise<Models.WafRuleRedirect>; + createRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + } + | string, + ...rest: [ + string?, + string?, + string?, + number?, + (string | null)?, + string?, + number?, + boolean?, + string[]?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType: string; + name: string; + location: string; + statusCode: number; + resourceId?: string | null; + description?: string; + priority?: number; + enabled?: boolean; + conditions?: string[]; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string, + name: rest[1] as string, + location: rest[2] as string, + statusCode: rest[3] as number, + resourceId: rest[4] as string | null, + description: rest[5] as string, + priority: rest[6] as number, + enabled: rest[7] as boolean, + conditions: rest[8] as string[], + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const name = params.name; + const location = params.location; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const description = params.description; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "resourceType"', + ); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof location === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "location"', + ); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException( + 'Missing required parameter: "statusCode"', + ); + } + const apiPath = '/waf/rules/redirect'; + const apiPayload: Payload = {}; + if (typeof ruleId !== 'undefined') { + apiPayload['ruleId'] = ruleId; + } + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} params.ruleId - Rule ID. + * @param {string | null} params.resourceType - Resource type the rule applies to. + * @param {string | null} params.resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} params.name - Rule name. + * @param {string | null} params.description - Optional description for the rule. + * @param {string | null} params.location - Location used for redirect responses. + * @param {number | null} params.statusCode - Integer status code used for redirect responses. + * @param {number | null} params.priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} params.enabled - Set to false to disable the rule. + * @param {string[] | null} params.conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + */ + updateRedirectRule(params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }): Promise<Models.WafRuleRedirect>; + /** + * Update a redirect WAF rule. Conditions can match request attributes including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and `state` require the premium Geo DB addon. + * + * + * @param {string} ruleId - Rule ID. + * @param {string | null} resourceType - Resource type the rule applies to. + * @param {string | null} resourceId - Resource identifier. Required for functions and sites. + * @param {string | null} name - Rule name. + * @param {string | null} description - Optional description for the rule. + * @param {string | null} location - Location used for redirect responses. + * @param {number | null} statusCode - Integer status code used for redirect responses. + * @param {number | null} priority - Evaluation priority. Lower numbers run earlier. + * @param {boolean | null} enabled - Set to false to disable the rule. + * @param {string[] | null} conditions - Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRedirectRule( + ruleId: string, + resourceType?: string | null, + resourceId?: string | null, + name?: string | null, + description?: string | null, + location?: string | null, + statusCode?: number | null, + priority?: number | null, + enabled?: boolean | null, + conditions?: string[] | null, + ): Promise<Models.WafRuleRedirect>; + updateRedirectRule( + paramsOrFirst: + | { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + } + | string, + ...rest: [ + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (string | null)?, + (number | null)?, + (number | null)?, + (boolean | null)?, + (string[] | null)?, + ] + ): Promise<Models.WafRuleRedirect> { + let params: { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { + ruleId: string; + resourceType?: string | null; + resourceId?: string | null; + name?: string | null; + description?: string | null; + location?: string | null; + statusCode?: number | null; + priority?: number | null; + enabled?: boolean | null; + conditions?: string[] | null; + }; + } else { + params = { + ruleId: paramsOrFirst as string, + resourceType: rest[0] as string | null, + resourceId: rest[1] as string | null, + name: rest[2] as string | null, + description: rest[3] as string | null, + location: rest[4] as string | null, + statusCode: rest[5] as number | null, + priority: rest[6] as number | null, + enabled: rest[7] as boolean | null, + conditions: rest[8] as string[] | null, + }; + } + + const ruleId = params.ruleId; + const resourceType = params.resourceType; + const resourceId = params.resourceId; + const name = params.name; + const description = params.description; + const location = params.location; + const statusCode = params.statusCode; + const priority = params.priority; + const enabled = params.enabled; + const conditions = params.conditions; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/redirect/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + if (typeof resourceType !== 'undefined') { + apiPayload['resourceType'] = resourceType; + } + if (typeof resourceId !== 'undefined') { + apiPayload['resourceId'] = resourceId; + } + if (typeof name !== 'undefined') { + apiPayload['name'] = name; + } + if (typeof description !== 'undefined') { + apiPayload['description'] = description; + } + if (typeof location !== 'undefined') { + apiPayload['location'] = location; + } + if (typeof statusCode !== 'undefined') { + apiPayload['statusCode'] = statusCode; + } + if (typeof priority !== 'undefined') { + apiPayload['priority'] = priority; + } + if (typeof enabled !== 'undefined') { + apiPayload['enabled'] = enabled; + } + if (typeof conditions !== 'undefined') { + apiPayload['conditions'] = conditions; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'wafRuleRedirect', + models: { + wafRuleRedirect: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + description: '', + teamId: '', + projectId: '', + resourceType: 'api', + resourceId: '', + priority: 0, + enabled: true, + conditions: [], + config: {}, + location: '/', + statusCode: 302, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); + } + + /** + * Get a WAF rule by its ID. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + */ + getRule(params: { + ruleId: string; + }): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + /** + * Get a WAF rule by its ID. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.WafRuleBypass | Models.WafRuleDeny | Models.WafRuleChallenge | Models.WafRuleRateLimit | Models.WafRuleRedirect>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule( + ruleId: string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + >; + getRule( + paramsOrFirst: { ruleId: string } | string, + ): Promise< + | Models.WafRuleBypass + | Models.WafRuleDeny + | Models.WafRuleChallenge + | Models.WafRuleRateLimit + | Models.WafRuleRedirect + > { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + accept: 'application/json', + }; + + return this.client.call('get', uri, apiHeaders, apiPayload); + } + + /** + * Delete a WAF rule. + * + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a WAF rule. + * + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule(paramsOrFirst: { ruleId: string } | string): Promise<{}> { + let params: { ruleId: string }; + + if ( + paramsOrFirst && + typeof paramsOrFirst === 'object' && + !Array.isArray(paramsOrFirst) + ) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string, + }; + } + + const ruleId = params.ruleId; + if (typeof ruleId === 'undefined' || ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + const apiPath = '/waf/rules/{ruleId}'.replace( + '{ruleId}', + encodeURIComponent(String(ruleId)), + ); + const apiPayload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'X-Appwrite-Project': this.client.config.project, + 'content-type': 'application/json', + accept: 'application/json', + }; + + return this.client.call('delete', uri, apiHeaders, apiPayload); + } +} diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index 0a61f59..32f492f 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -1,4 +1,9 @@ -import { AppwriteException, Client, type Payload } from '../client'; +import { + AppwriteException, + Client, + type Payload, + applyDefaults, +} from '../client'; import type { Models } from '../models'; export class Webhooks { @@ -70,7 +75,42 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhookList', + models: { + webhookList: { + defaults: { + total: 0, + webhooks: [], + }, + properties: { + webhooks: { + items: 'webhook', + }, + }, + }, + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -82,9 +122,9 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -97,7 +137,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -108,9 +148,9 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 2048 chars. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -124,7 +164,7 @@ export class Webhooks { tls?: boolean, authUsername?: string, authPassword?: string, - secret?: string, + secret?: string | null, ): Promise<Models.Webhook>; create( paramsOrFirst: @@ -137,7 +177,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; } | string, ...rest: [ @@ -148,7 +188,7 @@ export class Webhooks { boolean?, string?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -160,7 +200,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; if ( @@ -177,7 +217,7 @@ export class Webhooks { tls?: boolean; authUsername?: string; authPassword?: string; - secret?: string; + secret?: string | null; }; } else { params = { @@ -189,7 +229,7 @@ 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 | null, }; } @@ -253,7 +293,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('post', uri, apiHeaders, apiPayload); + const request = this.client.call('post', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -308,7 +372,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('get', uri, apiHeaders, apiPayload); + const request = this.client.call('get', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -320,8 +408,8 @@ export class Webhooks { * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {boolean} params.enabled - Enable or disable a webhook. * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. - * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} params.authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ @@ -333,7 +421,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }): Promise<Models.Webhook>; /** * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -344,8 +432,8 @@ export class Webhooks { * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {boolean} enabled - Enable or disable a webhook. * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. - * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. - * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 255 chars. + * @param {string | null} authPassword - Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. @@ -358,7 +446,7 @@ export class Webhooks { enabled?: boolean, tls?: boolean, authUsername?: string, - authPassword?: string, + authPassword?: string | null, ): Promise<Models.Webhook>; update( paramsOrFirst: @@ -370,7 +458,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; } | string, ...rest: [ @@ -380,7 +468,7 @@ export class Webhooks { boolean?, boolean?, string?, - string?, + (string | null)?, ] ): Promise<Models.Webhook> { let params: { @@ -391,7 +479,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; if ( @@ -407,7 +495,7 @@ export class Webhooks { enabled?: boolean; tls?: boolean; authUsername?: string; - authPassword?: string; + authPassword?: string | null; }; } else { params = { @@ -418,7 +506,7 @@ 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 | null, }; } @@ -478,7 +566,31 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('put', uri, apiHeaders, apiPayload); + const request = this.client.call('put', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } /** @@ -539,29 +651,32 @@ export class Webhooks { * 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. * * @param {string} params.webhookId - Webhook ID. - * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} */ updateSecret(params: { webhookId: string; - secret?: string; + secret?: string | null; }): Promise<Models.Webhook>; /** * 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. * * @param {string} webhookId - Webhook ID. - * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @param {string | null} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. * @throws {AppwriteException} * @returns {Promise<Models.Webhook>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; updateSecret( - paramsOrFirst: { webhookId: string; secret?: string } | string, - ...rest: [string?] + webhookId: string, + secret?: string | null, + ): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string; secret?: string | null } | string, + ...rest: [(string | null)?] ): Promise<Models.Webhook> { - let params: { webhookId: string; secret?: string }; + let params: { webhookId: string; secret?: string | null }; if ( paramsOrFirst && @@ -570,12 +685,12 @@ export class Webhooks { ) { params = (paramsOrFirst || {}) as { webhookId: string; - secret?: string; + secret?: string | null; }; } else { params = { webhookId: paramsOrFirst as string, - secret: rest[0] as string, + secret: rest[0] as string | null, }; } @@ -602,6 +717,30 @@ export class Webhooks { accept: 'application/json', }; - return this.client.call('patch', uri, apiHeaders, apiPayload); + const request = this.client.call('patch', uri, apiHeaders, apiPayload); + const defaults = { + root: 'webhook', + models: { + webhook: { + defaults: { + $id: '', + $createdAt: '', + $updatedAt: '', + name: '', + url: '', + events: [], + tls: true, + authUsername: '', + authPassword: '', + secret: '', + enabled: true, + logs: '', + attempts: 0, + }, + }, + }, + }; + + return request.then((response) => applyDefaults(response, defaults)); } } diff --git a/src/topic.ts b/src/topic.ts index cd6cea0..071d5ae 100644 --- a/src/topic.ts +++ b/src/topic.ts @@ -1,6 +1,6 @@ /** * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding - * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). + * the level separator `/` or the MQTT wildcards `+` and `#`. */ function levelsOf(levels: unknown): string[] { if (!Array.isArray(levels)) { @@ -28,17 +28,14 @@ function levelsOf(levels: unknown): string[] { `"${level}" contains "/", split it: path([${parts}])`, ); } - if (level === '+') { - throw new Error('"+" is reserved, use any()'); - } if (level.includes('+')) { - throw new Error(`"${level}" contains "+", use any() for wildcards`); - } - if (level === '#') { - throw new Error('"#" is reserved, use all()'); + throw new Error(`"${level}" contains "+", not allowed in a topic`); } if (level.includes('#')) { - throw new Error(`"${level}" contains "#", use all() for wildcards`); + throw new Error(`"${level}" contains "#", not allowed in a topic`); + } + if (level.includes('\0')) { + throw new Error(`level at index ${index} contains a NUL character`); } return level; }); @@ -48,11 +45,7 @@ function levelsOf(levels: unknown): string[] { * Helper to build MQTT topics for `Push`, level by level. * * Topic.path(['user', userId, 'notification']); // "user/123/notification" - * Topic.path(['user']).any().path(['notification']); // "user/+/notification" - * Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#" - * - * `any()` matches exactly one level and `all()` everything below, at any depth (including the - * parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}. + * Topic.path(['org', orgId]).path(['logs']); // "org/42/logs" */ export class Topic { private constructor(private readonly levels: readonly string[]) {} @@ -62,41 +55,11 @@ export class Topic { return new Topic(levelsOf(levels)); } - /** Start a topic with a single-level wildcard (`+`). */ - static any(): Topic { - return new Topic(['+']); - } - - /** The multi-level wildcard alone (`#`): matches every topic. */ - static all(): ResolvedTopic { - return new ResolvedTopic(['#']); - } - /** Append the given levels. */ path(levels: string[]): Topic { return new Topic([...this.levels, ...levelsOf(levels)]); } - /** Append a single-level wildcard (`+`): matches exactly one level. */ - any(): Topic { - return new Topic([...this.levels, '+']); - } - - /** Append the multi-level wildcard (`#`) and end the topic. */ - all(): ResolvedTopic { - return new ResolvedTopic([...this.levels, '#']); - } - - toString(): string { - return this.levels.join('/'); - } -} - -/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */ -export class ResolvedTopic { - /** @internal Created by {@link Topic.all}. */ - constructor(private readonly levels: readonly string[]) {} - toString(): string { return this.levels.join('/'); } diff --git a/test/client.test.js b/test/client.test.js index 71bda01..82b9451 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -1,5 +1,6 @@ const { Client } = require('../dist/client'); const { InputFile } = require('../dist/inputFile'); +const { Query } = require('../dist/query'); const { fetch: mockedFetch, Response, Dispatcher } = require('undici'); jest.mock('undici', () => ({ @@ -45,6 +46,58 @@ describe('Client', () => { }); }); +describe('Client.prepareRequest', () => { + const url = () => new URL('https://cloud.appwrite.io/v1/rows'); + const params = () => ({ + data: [['a', 'b']], + queries: Query.builder().equal('status', 'active').limit(1), + filters: [Query.equal('status', 'active'), Query.builder().limit(1)], + }); + const queries = [Query.equal('status', 'active'), Query.limit(1)]; + + test('sends nested string arrays and flattened builders as JSON', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'application/json' }, + params(), + ); + + expect(JSON.parse(options.body)).toEqual({ + data: [['a', 'b']], + queries, + filters: queries, + }); + }); + + test('sends nested string arrays and flattened builders as query string', () => { + const { uri } = new Client().prepareRequest('GET', url(), {}, params()); + const search = new URL(uri).searchParams; + + expect(search.get('data[0][0]')).toBe('a'); + expect(search.get('data[0][1]')).toBe('b'); + expect(search.has('data[0]')).toBe(false); + expect([search.get('queries[0]'), search.get('queries[1]')]).toEqual( + queries, + ); + expect([search.get('filters[0]'), search.get('filters[1]')]).toEqual( + queries, + ); + }); + + test('sends flattened builders as multipart fields', () => { + const { options } = new Client().prepareRequest( + 'POST', + url(), + { 'content-type': 'multipart/form-data' }, + params(), + ); + + expect(options.body.getAll('queries[]')).toEqual(queries); + expect(options.body.getAll('filters[]')).toEqual(queries); + }); +}); + describe('Client.chunkedUpload', () => { const url = new URL( 'https://cloud.appwrite.io/v1/storage/buckets/bucket/files', diff --git a/test/query.test.js b/test/query.test.js index 52e9490..1083ecd 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -1,35 +1,37 @@ -const { Query } = require('../dist/query'); +const { Query, normalizeQueries, flattenParam } = require('../dist/query'); + +const expectQuery = (query) => expect(JSON.parse(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'], }, ]; @@ -37,9 +39,11 @@ 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}}`, - ), + expectQuery(Query.equal('attr', t.value)).toEqual({ + method: 'equal', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -47,9 +51,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.notEqual('attr', t.value)).toEqual({ + method: 'notEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -57,9 +63,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThan('attr', t.value)).toEqual({ + method: 'lessThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -67,9 +75,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.lessThanEqual('attr', t.value)).toEqual({ + method: 'lessThanEqual', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -77,9 +87,11 @@ describe('Query', () => { 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}}`, - ), + expectQuery(Query.greaterThan('attr', t.value)).toEqual({ + method: 'greaterThan', + attribute: 'attr', + values: t.expectedValues, + }), ); } }); @@ -87,71 +99,402 @@ describe('Query', () => { 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}}`, - ), + expectQuery(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"]}`, - )); + expectQuery(Query.search('attr', 'keyword1 keyword2')).toEqual({ + method: 'search', + attribute: 'attr', + values: ['keyword1 keyword2'], + })); test('isNull', () => - expect(Query.isNull('attr')).toEqual( - `{"method":"isNull","attribute":"attr"}`, - )); + expectQuery(Query.isNull('attr')).toEqual({ + method: 'isNull', + attribute: 'attr', + })); test('isNotNull', () => - expect(Query.isNotNull('attr')).toEqual( - `{"method":"isNotNull","attribute":"attr"}`, - )); + expectQuery(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]}`, - )); + expectQuery(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]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(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"]}`, - )); + expectQuery(Query.select(['attr1', 'attr2'])).toEqual({ + method: 'select', + values: ['attr1', 'attr2'], + })); test('orderAsc', () => - expect(Query.orderAsc('attr')).toEqual( - `{"method":"orderAsc","attribute":"attr"}`, - )); + expectQuery(Query.orderAsc('attr')).toEqual({ + method: 'orderAsc', + attribute: 'attr', + })); test('orderDesc', () => - expect(Query.orderDesc('attr')).toEqual( - `{"method":"orderDesc","attribute":"attr"}`, - )); + expectQuery(Query.orderDesc('attr')).toEqual({ + method: 'orderDesc', + attribute: 'attr', + })); test('cursorBefore', () => - expect(Query.cursorBefore('attr')).toEqual( - '{"method":"cursorBefore","values":["attr"]}', - )); + expectQuery(Query.cursorBefore('attr')).toEqual({ + method: 'cursorBefore', + values: ['attr'], + })); test('cursorAfter', () => - expect(Query.cursorAfter('attr')).toEqual( - '{"method":"cursorAfter","values":["attr"]}', - )); + expectQuery(Query.cursorAfter('attr')).toEqual({ + method: 'cursorAfter', + values: ['attr'], + })); test('limit', () => - expect(Query.limit(1)).toEqual('{"method":"limit","values":[1]}')); + expectQuery(Query.limit(1)).toEqual({ method: 'limit', values: [1] })); test('offset', () => - expect(Query.offset(1)).toEqual('{"method":"offset","values":[1]}')); + expectQuery(Query.offset(1)).toEqual({ + method: 'offset', + values: [1], + })); + + test('count with alias', () => + expectQuery(Query.count('*', 'total')).toEqual({ + method: 'count', + attribute: '*', + values: ['total'], + })); + + test('count without alias', () => + expectQuery(Query.count()).toEqual({ + method: 'count', + attribute: '*', + })); + + test('countDistinct', () => + expectQuery(Query.countDistinct('year', 'uniqueYears')).toEqual({ + method: 'countDistinct', + attribute: 'year', + values: ['uniqueYears'], + })); + + test('sum', () => + expectQuery(Query.sum('price', 'total')).toEqual({ + method: 'sum', + attribute: 'price', + values: ['total'], + })); + + test('avg', () => + expectQuery(Query.avg('price', 'avgPrice')).toEqual({ + method: 'avg', + attribute: 'price', + values: ['avgPrice'], + })); + + test('min', () => + expectQuery(Query.min('price', 'lowest')).toEqual({ + method: 'min', + attribute: 'price', + values: ['lowest'], + })); + + test('max', () => + expectQuery(Query.max('price', 'highest')).toEqual({ + method: 'max', + attribute: 'price', + values: ['highest'], + })); + + test('stddev', () => + expectQuery(Query.stddev('price', 'sd')).toEqual({ + method: 'stddev', + attribute: 'price', + values: ['sd'], + })); + + test('stddevPop', () => + expectQuery(Query.stddevPop('price', 'sdp')).toEqual({ + method: 'stddevPop', + attribute: 'price', + values: ['sdp'], + })); + + test('stddevSamp', () => + expectQuery(Query.stddevSamp('price', 'sds')).toEqual({ + method: 'stddevSamp', + attribute: 'price', + values: ['sds'], + })); + + test('variance', () => + expectQuery(Query.variance('price', 'var')).toEqual({ + method: 'variance', + attribute: 'price', + values: ['var'], + })); + + test('varPop', () => + expectQuery(Query.varPop('price', 'vp')).toEqual({ + method: 'varPop', + attribute: 'price', + values: ['vp'], + })); + + test('varSamp', () => + expectQuery(Query.varSamp('price', 'vs')).toEqual({ + method: 'varSamp', + attribute: 'price', + values: ['vs'], + })); + + test('bitAnd', () => + expectQuery(Query.bitAnd('flags', 'band')).toEqual({ + method: 'bitAnd', + attribute: 'flags', + values: ['band'], + })); + + test('bitOr', () => + expectQuery(Query.bitOr('flags', 'bor')).toEqual({ + method: 'bitOr', + attribute: 'flags', + values: ['bor'], + })); + + test('bitXor', () => + expectQuery(Query.bitXor('flags', 'bxor')).toEqual({ + method: 'bitXor', + attribute: 'flags', + values: ['bxor'], + })); + + test('groupBy', () => + expectQuery(Query.groupBy(['status', 'year'])).toEqual({ + method: 'groupBy', + values: ['status', 'year'], + })); + + test('having nests parsed queries', () => { + const having = JSON.parse( + Query.having([Query.greaterThan('total', 1)]), + ); + expect(having.method).toEqual('having'); + expect(having.values[0].method).toEqual('greaterThan'); + expect(having.values[0].attribute).toEqual('total'); + expect(having.values[0].values).toEqual([1]); + }); + + test('distinct', () => + expectQuery(Query.distinct()).toEqual({ method: 'distinct' })); + + test('join', () => + expectQuery(Query.join('orders', '$id', 'customerId')).toEqual({ + method: 'join', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('leftJoin with alias', () => + expectQuery( + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + ).toEqual({ + method: 'leftJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId', 'ord'], + })); + + test('rightJoin', () => + expectQuery(Query.rightJoin('orders', '$id', 'customerId')).toEqual({ + method: 'rightJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + })); + + test('fullOuterJoin', () => + expectQuery(Query.fullOuterJoin('orders', '$id', 'customerId')).toEqual( + { + method: 'fullOuterJoin', + attribute: 'orders', + values: ['$id', '=', 'customerId'], + }, + )); + + test('on', () => + expectQuery(Query.on('$id', 'customerId')).toEqual({ + method: 'on', + values: ['$id', '=', 'customerId'], + })); + + test('nested leftJoin', () => { + const query = JSON.parse( + Query.leftJoin('orders', 'ord', [ + Query.on('$id', 'customerId'), + Query.equal('ord.status', 'paid'), + ]), + ); + expect(query.method).toEqual('leftJoin'); + expect(query.attribute).toEqual('orders'); + expect(query.values[0]).toEqual('ord'); + expect(query.values[1].method).toEqual('on'); + expect(query.values[2].method).toEqual('equal'); + }); + + test('crossJoin', () => + expectQuery(Query.crossJoin('orders', 'ord')).toEqual({ + method: 'crossJoin', + attribute: 'orders', + values: ['ord'], + })); + + test('vectorDot', () => + expectQuery(Query.vectorDot('embedding', [0.1, 0.2])).toEqual({ + method: 'vectorDot', + attribute: 'embedding', + values: [[0.1, 0.2]], + })); + + test('notCovers', () => + expectQuery(Query.notCovers('location', [1, 2])).toEqual({ + method: 'notCovers', + attribute: 'location', + values: [[1, 2]], + })); + + test('spatialEquals', () => + expectQuery(Query.spatialEquals('location', [1, 2])).toEqual({ + method: 'spatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('notSpatialEquals', () => + expectQuery(Query.notSpatialEquals('location', [1, 2])).toEqual({ + method: 'notSpatialEquals', + attribute: 'location', + values: [[1, 2]], + })); + + test('page', () => { + const queries = Query.page(2, 10).map((query) => JSON.parse(query)); + expect(queries).toEqual([ + { method: 'limit', values: [10] }, + { method: 'offset', values: [10] }, + ]); + }); + + test('builder build', () => { + const built = Query.builder() + .equal('status', 'published') + .leftJoin('orders', '$id', 'customerId', '=', 'ord') + .count('*', 'total') + .groupBy(['status']) + .limit(25) + .build(); + + expect(built).toEqual([ + Query.equal('status', 'published'), + Query.leftJoin('orders', '$id', 'customerId', '=', 'ord'), + Query.count('*', 'total'), + Query.groupBy(['status']), + Query.limit(25), + ]); + }); + + test('normalize builder wrapped in array', () => { + const builder = Query.builder().equal('status', 'active').limit(10); + expect(normalizeQueries([builder])).toEqual(builder.build()); + expect(normalizeQueries([builder.build()])).toEqual(builder.build()); + expect(normalizeQueries(builder)).toEqual(builder.build()); + }); + + test('normalize page wrapped in array', () => { + expect( + normalizeQueries([ + Query.equal('status', 'active'), + Query.page(2, 10), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(10), + Query.offset(10), + ]); + }); + + test('flattenParam spreads wrapped builder', () => { + expect(flattenParam([Query.builder().limit(1)])).toEqual([ + Query.limit(1), + ]); + }); + + test('flattenParam keeps nested numeric arrays', () => { + const geometry = [ + [1, 2], + [3, 4], + ]; + expect(flattenParam(geometry)).toEqual(geometry); + }); + + test('flattenParam keeps query string list', () => { + expect(flattenParam([Query.limit(1)])).toEqual([Query.limit(1)]); + }); + + test('flattenParam keeps nested string arrays', () => { + const value = [['a', 'b']]; + expect(flattenParam(value)).toEqual([['a', 'b']]); + }); + + test('flattenParam builds builders nested in arrays', () => { + expect(flattenParam([[Query.builder().limit(1)]])).toEqual([ + [Query.limit(1)], + ]); + }); + + test('flattenParam builds a builder value', () => { + expect( + flattenParam(Query.builder().equal('status', 'active').limit(1)), + ).toEqual([Query.equal('status', 'active'), Query.limit(1)]); + }); + + test('flattenParam splices builders among query strings', () => { + expect( + flattenParam([ + Query.equal('status', 'active'), + Query.builder().limit(1).offset(2), + ]), + ).toEqual([ + Query.equal('status', 'active'), + Query.limit(1), + Query.offset(2), + ]); + }); }); diff --git a/test/services/account.test.js b/test/services/account.test.js index 5308e90..0bd3f1c 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -13,9 +13,9 @@ describe('Account', () => { 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', + $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, @@ -40,9 +40,9 @@ describe('Account', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Account', () => { }); 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', + $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', @@ -129,9 +129,9 @@ describe('Account', () => { }); 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', + $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', @@ -168,9 +168,9 @@ describe('Account', () => { }); 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', + $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, @@ -221,9 +221,9 @@ describe('Account', () => { }); 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', + $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, @@ -274,9 +274,9 @@ describe('Account', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Account', () => { }); 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', + $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, @@ -348,8 +348,8 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -363,8 +363,8 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', }; @@ -378,9 +378,9 @@ describe('Account', () => { }); 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', + $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', @@ -421,9 +421,9 @@ describe('Account', () => { }); 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', + $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', @@ -568,9 +568,9 @@ describe('Account', () => { }); 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', + $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, @@ -593,11 +593,101 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.listPasskeys(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createPasskey()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskey(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.getPasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskey('<PASSKEY_ID>', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.deletePasskey('<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyVerification()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyVerification( + '<PASSKEY_ID>', + {}, + ); + + // 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', + $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, @@ -622,9 +712,9 @@ describe('Account', () => { }); 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', + $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, @@ -659,9 +749,9 @@ describe('Account', () => { }); 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', + $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, @@ -686,8 +776,8 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -706,8 +796,8 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -727,8 +817,8 @@ describe('Account', () => { }); test('test method createRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -744,8 +834,8 @@ describe('Account', () => { }); test('test method updateRecoveryOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -788,9 +878,9 @@ describe('Account', () => { }); 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', + $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', @@ -828,9 +918,9 @@ describe('Account', () => { }); 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', + $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', @@ -871,9 +961,9 @@ describe('Account', () => { }); test('test method createIdTokenSession()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -914,9 +1004,9 @@ describe('Account', () => { }); 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', + $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', @@ -957,9 +1047,9 @@ describe('Account', () => { }); 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', + $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', @@ -1000,9 +1090,9 @@ describe('Account', () => { }); 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', + $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', @@ -1040,9 +1130,9 @@ describe('Account', () => { }); 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', + $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', @@ -1080,9 +1170,9 @@ describe('Account', () => { }); 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', + $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', @@ -1130,9 +1220,9 @@ describe('Account', () => { }); 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', + $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, @@ -1157,8 +1247,8 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1177,8 +1267,8 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1205,10 +1295,43 @@ describe('Account', () => { expect(response).toEqual(data); }); + test('test method createPasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + passkeyId: '5e5ea5c16897e', + expire: '2020-10-15T06:38:00.000+00:00', + publicKey: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.createPasskeyToken(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskeyToken()', async () => { + const data = { + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await account.updatePasskeyToken('<CHALLENGE_ID>', {}); + + // 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', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1227,8 +1350,8 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1246,8 +1369,8 @@ describe('Account', () => { }); test('test method createVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1265,8 +1388,8 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1285,8 +1408,8 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1305,8 +1428,8 @@ describe('Account', () => { }); test('test method createEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1322,8 +1445,8 @@ describe('Account', () => { }); test('test method updateEmailVerificationOTP()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1342,8 +1465,8 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -1359,8 +1482,8 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index 5270074..4c59cab 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', actorType: 'user', actorId: '610fc2f985ee0', actorEmail: 'john@appwrite.io', diff --git a/test/services/advisor.test.js b/test/services/advisor.test.js index 777728a..b3ff64d 100644 --- a/test/services/advisor.test.js +++ b/test/services/advisor.test.js @@ -26,9 +26,9 @@ describe('Advisor', () => { }); 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', + $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/', @@ -71,9 +71,9 @@ describe('Advisor', () => { }); 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', + $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', diff --git a/test/services/apps.test.js b/test/services/apps.test.js index d79c42c..a63e37e 100644 --- a/test/services/apps.test.js +++ b/test/services/apps.test.js @@ -26,9 +26,9 @@ describe('Apps', () => { }); 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', + $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', @@ -89,9 +89,9 @@ describe('Apps', () => { }); 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', + $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', @@ -126,9 +126,9 @@ describe('Apps', () => { }); 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', + $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', @@ -186,9 +186,9 @@ describe('Apps', () => { }); 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', + $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: [], @@ -254,9 +254,9 @@ describe('Apps', () => { }); 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', + $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', @@ -273,9 +273,9 @@ describe('Apps', () => { }); 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', + $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', @@ -302,9 +302,9 @@ describe('Apps', () => { }); 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', + $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', @@ -352,9 +352,9 @@ describe('Apps', () => { }); 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', + $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', @@ -371,9 +371,9 @@ describe('Apps', () => { }); 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', + $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', @@ -400,9 +400,9 @@ describe('Apps', () => { }); 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', + $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', diff --git a/test/services/avatars.test.js b/test/services/avatars.test.js index c65b1b9..ecd4504 100644 --- a/test/services/avatars.test.js +++ b/test/services/avatars.test.js @@ -84,9 +84,9 @@ describe('Avatars', () => { }); test('test method updatePhoto()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, diff --git a/test/services/backups.test.js b/test/services/backups.test.js index 922f68d..e1db580 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -26,9 +26,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -45,9 +45,9 @@ describe('Backups', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', policyId: 'did8jx6ws45jana098ab7', status: 'completed', migrationId: 'did8jx6ws45jana098ab7', @@ -87,10 +87,10 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -113,10 +113,10 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -134,10 +134,10 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -165,9 +165,9 @@ describe('Backups', () => { }); 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', + $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', @@ -199,9 +199,9 @@ describe('Backups', () => { }); 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', + $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', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 2af87b0..502bcb0 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -26,10 +26,10 @@ describe('Databases', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -56,9 +56,9 @@ describe('Databases', () => { }); 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', + $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', @@ -73,9 +73,9 @@ describe('Databases', () => { }); 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', + $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', @@ -90,9 +90,9 @@ describe('Databases', () => { }); 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', + $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', @@ -117,9 +117,9 @@ describe('Databases', () => { }); 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', + $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', @@ -134,10 +134,10 @@ describe('Databases', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -151,10 +151,10 @@ describe('Databases', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,10 +191,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -218,10 +218,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -244,10 +244,10 @@ describe('Databases', () => { }); 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': [], + $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, @@ -304,8 +304,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -327,8 +327,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -351,8 +351,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -374,8 +374,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -398,8 +398,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -422,8 +422,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -447,8 +447,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -471,8 +471,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -496,8 +496,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -522,8 +522,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -549,8 +549,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -572,8 +572,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -596,8 +596,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -619,8 +619,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -643,8 +643,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -667,8 +667,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -692,8 +692,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -715,8 +715,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -738,8 +738,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -761,8 +761,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -785,8 +785,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -808,8 +808,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -832,8 +832,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -855,8 +855,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -878,8 +878,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -901,8 +901,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -924,8 +924,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -953,8 +953,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -981,8 +981,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1006,8 +1006,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1031,8 +1031,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1054,8 +1054,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1078,8 +1078,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1102,8 +1102,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1127,8 +1127,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1152,8 +1152,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1177,8 +1177,8 @@ describe('Databases', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1225,13 +1225,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1314,13 +1314,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1336,13 +1336,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1358,13 +1358,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1394,13 +1394,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1417,13 +1417,13 @@ describe('Databases', () => { }); 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': [], + $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( @@ -1456,9 +1456,9 @@ describe('Databases', () => { }); 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', + $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', @@ -1482,9 +1482,9 @@ describe('Databases', () => { }); 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', + $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', diff --git a/test/services/documents-d-b.test.js b/test/services/documents-d-b.test.js index 3966455..b56872d 100644 --- a/test/services/documents-d-b.test.js +++ b/test/services/documents-d-b.test.js @@ -26,10 +26,10 @@ describe('DocumentsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -132,9 +132,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -149,10 +149,10 @@ describe('DocumentsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -166,10 +166,10 @@ describe('DocumentsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -206,10 +206,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -259,10 +259,10 @@ describe('DocumentsDB', () => { }); 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': [], + $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, @@ -315,13 +315,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -404,13 +404,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -426,13 +426,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -448,13 +448,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -484,13 +484,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -507,13 +507,13 @@ describe('DocumentsDB', () => { }); 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': [], + $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( @@ -546,9 +546,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -572,9 +572,9 @@ describe('DocumentsDB', () => { }); 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', + $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', @@ -610,21 +610,17 @@ describe('DocumentsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/domains.test.js b/test/services/domains.test.js index fc86018..f77cb0e 100644 --- a/test/services/domains.test.js +++ b/test/services/domains.test.js @@ -26,9 +26,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -79,9 +79,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -112,9 +112,9 @@ describe('Domains', () => { }); test('test method updateNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -135,9 +135,9 @@ describe('Domains', () => { }); test('test method verifyNameservers()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -328,9 +328,9 @@ describe('Domains', () => { }); test('test method createRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -356,9 +356,9 @@ describe('Domains', () => { }); test('test method updateRecordA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -385,9 +385,9 @@ describe('Domains', () => { }); test('test method createRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -413,9 +413,9 @@ describe('Domains', () => { }); test('test method updateRecordAAAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -442,9 +442,9 @@ describe('Domains', () => { }); test('test method createRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -470,9 +470,9 @@ describe('Domains', () => { }); test('test method updateRecordAlias()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -499,9 +499,9 @@ describe('Domains', () => { }); test('test method createRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -527,9 +527,9 @@ describe('Domains', () => { }); test('test method updateRecordCAA()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -556,9 +556,9 @@ describe('Domains', () => { }); test('test method createRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -584,9 +584,9 @@ describe('Domains', () => { }); test('test method updateRecordCNAME()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -613,9 +613,9 @@ describe('Domains', () => { }); test('test method createRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -641,9 +641,9 @@ describe('Domains', () => { }); test('test method updateRecordHTTPS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -670,9 +670,9 @@ describe('Domains', () => { }); test('test method createRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -699,9 +699,9 @@ describe('Domains', () => { }); test('test method updateRecordMX()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -729,9 +729,9 @@ describe('Domains', () => { }); test('test method createRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -757,9 +757,9 @@ describe('Domains', () => { }); test('test method updateRecordNS()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -786,9 +786,9 @@ describe('Domains', () => { }); test('test method createRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -817,9 +817,9 @@ describe('Domains', () => { }); test('test method updateRecordSRV()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -849,9 +849,9 @@ describe('Domains', () => { }); test('test method createRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -876,9 +876,9 @@ describe('Domains', () => { }); test('test method updateRecordTXT()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -905,9 +905,9 @@ describe('Domains', () => { }); test('test method getRecord()', async () => { const data = { - '\\$id': '5f40a6e10c65e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5f40a6e10c65e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', type: 'A', name: 'mail', value: '192.0.2.1', @@ -941,9 +941,9 @@ describe('Domains', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', @@ -988,9 +988,9 @@ describe('Domains', () => { }); test('test method updateZone()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', domain: 'example.com', registrar: 'appwrite', nameservers: 'Appwrite', diff --git a/test/services/functions.test.js b/test/services/functions.test.js index fba574b..78f0a33 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -27,9 +27,9 @@ describe('Functions', () => { }); 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', + $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, @@ -59,6 +59,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.create( @@ -100,9 +101,9 @@ describe('Functions', () => { }); 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', + $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, @@ -132,6 +133,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.get('<FUNCTION_ID>'); @@ -143,9 +145,9 @@ describe('Functions', () => { }); 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', + $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, @@ -175,6 +177,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.update('<FUNCTION_ID>', '<NAME>'); @@ -196,9 +199,9 @@ describe('Functions', () => { }); 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', + $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, @@ -228,6 +231,7 @@ describe('Functions', () => { providerPaths: [], buildSpecification: 's-1vcpu-512mb', runtimeSpecification: 's-1vcpu-512mb', + emailEnabled: true, }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.updateFunctionDeployment( @@ -255,9 +259,9 @@ describe('Functions', () => { }); 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', + $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', @@ -300,9 +304,9 @@ describe('Functions', () => { }); 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', + $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', @@ -344,9 +348,9 @@ describe('Functions', () => { }); 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', + $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', @@ -392,9 +396,9 @@ describe('Functions', () => { }); 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', + $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', @@ -437,9 +441,9 @@ describe('Functions', () => { }); 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', + $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', @@ -507,9 +511,9 @@ describe('Functions', () => { }); 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', + $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', @@ -564,10 +568,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -593,10 +597,10 @@ describe('Functions', () => { }); 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': [], + $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', @@ -651,9 +655,9 @@ describe('Functions', () => { }); 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', + $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, @@ -675,9 +679,9 @@ describe('Functions', () => { }); 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', + $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, @@ -697,9 +701,9 @@ describe('Functions', () => { }); 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', + $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, diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 25df258..3ffc4e3 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -26,9 +26,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -51,9 +51,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -72,9 +72,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -93,9 +93,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -114,9 +114,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -135,9 +135,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -156,9 +156,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -177,9 +177,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -198,9 +198,9 @@ describe('Messaging', () => { }); 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', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', providerType: 'email', topics: [], users: [], @@ -255,9 +255,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -277,9 +277,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -299,9 +299,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -318,9 +318,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -337,9 +337,9 @@ describe('Messaging', () => { }); test('test method createAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -359,9 +359,9 @@ describe('Messaging', () => { }); test('test method updateAppwriteProvider()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -379,9 +379,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -401,9 +401,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -423,9 +423,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -442,9 +442,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -461,9 +461,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -483,9 +483,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -502,9 +502,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -524,9 +524,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -543,9 +543,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -565,9 +565,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -584,9 +584,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -606,9 +606,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -626,9 +626,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -648,9 +648,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -667,9 +667,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -690,9 +690,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -713,9 +713,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -732,9 +732,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -751,9 +751,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -773,9 +773,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -793,9 +793,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -815,9 +815,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -835,9 +835,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -857,9 +857,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -876,9 +876,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -898,9 +898,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -917,9 +917,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -959,9 +959,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -978,9 +978,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -997,9 +997,9 @@ describe('Messaging', () => { }); 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', + $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, @@ -1039,9 +1039,9 @@ describe('Messaging', () => { }); 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', + $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', @@ -1063,9 +1063,9 @@ describe('Messaging', () => { }); 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', + $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', diff --git a/test/services/mongo.test.js b/test/services/mongo.test.js index 748ff58..9430d54 100644 --- a/test/services/mongo.test.js +++ b/test/services/mongo.test.js @@ -26,21 +26,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mongo', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mongo', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mongo', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mongo', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mongo', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mongo', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -586,21 +566,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -647,21 +623,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -712,21 +684,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -829,17 +797,13 @@ describe('Mongo', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -852,17 +816,13 @@ describe('Mongo', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -876,6 +836,28 @@ describe('Mongo', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mongo.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -900,21 +882,17 @@ describe('Mongo', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/mysql.test.js b/test/services/mysql.test.js index 30e05cf..29ef428 100644 --- a/test/services/mysql.test.js +++ b/test/services/mysql.test.js @@ -26,21 +26,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Mysql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Mysql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Mysql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Mysql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Mysql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -442,21 +430,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -503,21 +487,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -567,8 +547,8 @@ describe('Mysql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -603,21 +583,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -664,21 +640,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -729,21 +701,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -888,17 +856,13 @@ describe('Mysql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -911,17 +875,13 @@ describe('Mysql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -935,6 +895,28 @@ describe('Mysql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await mysql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -959,21 +941,17 @@ describe('Mysql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/oauth2.test.js b/test/services/oauth2.test.js index 476045a..79d73e5 100644 --- a/test/services/oauth2.test.js +++ b/test/services/oauth2.test.js @@ -70,9 +70,9 @@ describe('Oauth2', () => { }); 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', + $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: [], @@ -94,9 +94,9 @@ describe('Oauth2', () => { }); 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', + $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: [], diff --git a/test/services/organization.test.js b/test/services/organization.test.js index 6437dd6..e955287 100644 --- a/test/services/organization.test.js +++ b/test/services/organization.test.js @@ -13,9 +13,9 @@ describe('Organization', () => { 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', + $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: {}, @@ -24,13 +24,6 @@ describe('Organization', () => { 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', @@ -46,9 +39,9 @@ describe('Organization', () => { }); 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', + $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: {}, @@ -57,13 +50,6 @@ describe('Organization', () => { 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', @@ -102,9 +88,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -122,9 +108,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -143,9 +129,9 @@ describe('Organization', () => { }); 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', + $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: [], @@ -188,9 +174,9 @@ describe('Organization', () => { }); 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', + $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', @@ -214,9 +200,9 @@ describe('Organization', () => { }); 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', + $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', @@ -240,9 +226,9 @@ describe('Organization', () => { }); 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', + $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', @@ -292,9 +278,9 @@ describe('Organization', () => { }); 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', + $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', @@ -332,9 +318,9 @@ describe('Organization', () => { }); 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', + $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', @@ -369,9 +355,9 @@ describe('Organization', () => { }); 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', + $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', @@ -432,9 +418,9 @@ describe('Organization', () => { }); test('test method createEphemeralProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -456,9 +442,9 @@ describe('Organization', () => { }); test('test method getProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], @@ -479,9 +465,9 @@ describe('Organization', () => { }); test('test method updateProjectKey()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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: [], diff --git a/test/services/postgresql.test.js b/test/services/postgresql.test.js index f002ac0..3b5fe88 100644 --- a/test/services/postgresql.test.js +++ b/test/services/postgresql.test.js @@ -26,21 +26,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -100,21 +96,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -161,21 +153,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -245,8 +233,8 @@ describe('Postgresql', () => { }); test('test method createBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -282,10 +270,10 @@ describe('Postgresql', () => { }); test('test method createBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -309,10 +297,10 @@ describe('Postgresql', () => { }); test('test method getBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -333,10 +321,10 @@ describe('Postgresql', () => { }); test('test method updateBackupPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'Hourly backups', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', services: [], resources: [], retention: 7, @@ -392,8 +380,8 @@ describe('Postgresql', () => { }); test('test method getBackup()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', policyId: '5e5ea5c16897e', @@ -445,21 +433,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -506,21 +490,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -570,8 +550,8 @@ describe('Postgresql', () => { }); test('test method updateCredentials()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', type: 'update', status: 'completed', @@ -623,21 +603,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -687,21 +663,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -751,21 +723,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -812,21 +780,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -877,21 +841,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -1039,17 +999,13 @@ describe('Postgresql', () => { }); test('test method createRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1062,17 +1018,13 @@ describe('Postgresql', () => { }); test('test method getRestoration()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', databaseId: '5e5ea5c16897e', - sourceDatabaseId: '5e5ea5c16897e', projectId: '5e5ea5c16897e', - backupId: '5e5ea5c16897e', type: 'backup', + restoreMode: 'clone', 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)); @@ -1086,6 +1038,28 @@ describe('Postgresql', () => { expect(response).toEqual(data); }); + test('test method promoteRestoration()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + databaseId: '5e5ea5c16897e', + projectId: '5e5ea5c16897e', + type: 'backup', + restoreMode: 'clone', + status: 'completed', + error: '', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await postgresql.promoteRestoration( + '<DATABASE_ID>', + '<RESTORATION_ID>', + ); + + // 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', @@ -1110,21 +1084,17 @@ describe('Postgresql', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/presences.test.js b/test/services/presences.test.js index b388216..ee08169 100644 --- a/test/services/presences.test.js +++ b/test/services/presences.test.js @@ -26,10 +26,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -43,10 +43,10 @@ describe('Presences', () => { }); 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': [], + $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', }; @@ -64,10 +64,10 @@ describe('Presences', () => { }); 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': [], + $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', }; diff --git a/test/services/project.test.js b/test/services/project.test.js index de5af44..13066dc 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -13,9 +13,9 @@ describe('Project', () => { 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', + $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', @@ -60,9 +60,9 @@ describe('Project', () => { }); 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', + $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', @@ -95,6 +95,146 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method listEnvironments()', async () => { + const data = { + total: 5, + projects: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.listEnvironments(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.createEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.getEnvironment('<ENVIRONMENT_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateEnvironment()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updateEnvironment( + '<ENVIRONMENT_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteEnvironment()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.deleteEnvironment('<ENVIRONMENT_ID>'); + + // 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, @@ -110,9 +250,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -130,9 +270,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -150,9 +290,9 @@ describe('Project', () => { }); 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', + $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: [], @@ -180,9 +320,9 @@ describe('Project', () => { }); 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', + $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', @@ -232,8 +372,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -247,8 +387,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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'); @@ -262,8 +402,8 @@ describe('Project', () => { const data = { number: '+1612842323', otp: '123456', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', '<OTP>'); @@ -298,9 +438,9 @@ describe('Project', () => { }); 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', + $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', @@ -338,7 +478,7 @@ describe('Project', () => { }); test('test method updateOAuth2Amazon()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', @@ -355,7 +495,7 @@ describe('Project', () => { }); test('test method updateOAuth2Apple()', async () => { const data = { - '\\$id': 'apple', + $id: 'apple', enabled: true, serviceId: 'ip.appwrite.app.web', keyId: 'P4000000N8', @@ -374,7 +514,7 @@ describe('Project', () => { }); test('test method updateOAuth2Appwrite()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a42000000000000b5a0', clientSecret: @@ -390,7 +530,7 @@ describe('Project', () => { }); test('test method updateOAuth2Auth0()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'OaOkIA000000000000000000005KLSYq', clientSecret: @@ -408,7 +548,7 @@ describe('Project', () => { }); test('test method updateOAuth2Authentik()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dTKOPa0000000000000000000000000000e7G8hv', clientSecret: @@ -425,7 +565,7 @@ describe('Project', () => { }); test('test method updateOAuth2Autodesk()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '5zw90v00000000000000000000kVYXN7', clientSecret: '7I000000000000MW', @@ -440,7 +580,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitbucket()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, key: 'Knt70000000000ByRc', secret: 'NMfLZJ00000000000000000000TLQdDx', @@ -455,7 +595,7 @@ describe('Project', () => { }); test('test method updateOAuth2Bitly()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'd95151000000000000000000000000000067af9b', clientSecret: 'a13e250000000000000000000000000000d73095', @@ -470,7 +610,7 @@ describe('Project', () => { }); test('test method updateOAuth2Box()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'deglcs00000000000000000000x2og6y', clientSecret: 'OKM1f100000000000000000000eshEif', @@ -485,7 +625,7 @@ describe('Project', () => { }); test('test method updateOAuth2Cloudflare()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '4b866000000000000000000000c9e4e2', clientSecret: @@ -501,7 +641,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dailymotion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, apiKey: '07a9000000000000067f', apiSecret: 'a399a90000000000000000000000000000d90639', @@ -516,7 +656,7 @@ describe('Project', () => { }); test('test method updateOAuth2Discord()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '950722000000343754', clientSecret: 'YmPXnM000000000000000000002zFg5D', @@ -532,7 +672,7 @@ describe('Project', () => { }); test('test method updateOAuth2Disqus()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, publicKey: 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', @@ -549,7 +689,7 @@ describe('Project', () => { }); test('test method updateOAuth2Dropbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appKey: 'jl000000000009t', appSecret: 'g200000000000vw', @@ -564,7 +704,7 @@ describe('Project', () => { }); test('test method updateOAuth2Etsy()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, keyString: 'nsgzxh0000000000008j85a2', sharedSecret: 'tp000000ru', @@ -579,7 +719,7 @@ describe('Project', () => { }); test('test method updateOAuth2Facebook()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, appId: '260600000007694', appSecret: '2d0b2800000000000000000000d38af4', @@ -594,7 +734,7 @@ describe('Project', () => { }); test('test method updateOAuth2Figma()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'byay5H0000000000VtiI40', clientSecret: 'yEpOYn0000000000000000004iIsU5', @@ -609,7 +749,7 @@ describe('Project', () => { }); test('test method updateOAuth2FusionAuth()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'b2222c00-0000-0000-0000-000000862097', clientSecret: 'Jx4s0C0000000000000000000000000000000wGqLsc', @@ -625,7 +765,7 @@ describe('Project', () => { }); test('test method updateOAuth2GitHub()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'e4d87900000000540733', clientSecret: '5e07c00000000000000000000000000000198bcc', @@ -641,7 +781,7 @@ describe('Project', () => { }); test('test method updateOAuth2Gitlab()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', @@ -658,7 +798,7 @@ describe('Project', () => { }); test('test method updateOAuth2Google()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com', @@ -677,7 +817,7 @@ describe('Project', () => { }); test('test method updateOAuth2HuggingFace()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '2ab9cff9-d711-40ad-a91e-b08a49c42d24', clientSecret: 'oauth_app_secret_wcLhRtl000000000000000000000xbNdLt', @@ -692,7 +832,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kakao()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -708,7 +848,7 @@ describe('Project', () => { }); test('test method updateOAuth2Keycloak()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-o0000000st-app', clientSecret: 'jdjrJd00000000000000000000HUsaZO', @@ -725,7 +865,7 @@ describe('Project', () => { }); test('test method updateOAuth2Kick()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '01KQ7C00000000000001MFHS32', clientSecret: @@ -741,7 +881,7 @@ describe('Project', () => { }); test('test method updateOAuth2Linkedin()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '770000000000dv', primaryClientSecret: 'WPL_AP1.2Bf0000000000000./HtlYw==', @@ -756,7 +896,7 @@ describe('Project', () => { }); test('test method updateOAuth2Microsoft()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, applicationId: '00001111-aaaa-2222-bbbb-3333cccc4444', applicationSecret: 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', @@ -773,7 +913,7 @@ describe('Project', () => { }); test('test method updateOAuth2Notion()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauthClientId: '341d8700-0000-0000-0000-000000446ee3', oauthClientSecret: @@ -789,7 +929,7 @@ describe('Project', () => { }); test('test method updateOAuth2Oidc()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'qibI2x0000000000000000000000000006L2YFoG', clientSecret: @@ -811,7 +951,7 @@ describe('Project', () => { }); test('test method updateOAuth2Okta()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '0oa00000000000000698', clientSecret: @@ -830,7 +970,7 @@ describe('Project', () => { }); test('test method updateOAuth2Paypal()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -847,7 +987,7 @@ describe('Project', () => { }); test('test method updateOAuth2PaypalSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', @@ -864,7 +1004,7 @@ describe('Project', () => { }); test('test method updateOAuth2Podio()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'appwrite-oauth-test-app', clientSecret: @@ -880,7 +1020,7 @@ describe('Project', () => { }); test('test method updateOAuth2Resend()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', clientSecret: @@ -896,7 +1036,7 @@ describe('Project', () => { }); test('test method updateOAuth2Salesforce()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', @@ -913,7 +1053,7 @@ describe('Project', () => { }); test('test method updateOAuth2Slack()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '23000000089.15000000000023', clientSecret: '81656000000000000000000000f3d2fd', @@ -928,7 +1068,7 @@ describe('Project', () => { }); test('test method updateOAuth2Spotify()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6ec271000000000000000000009beace', clientSecret: 'db068a000000000000000000008b5b9f', @@ -943,7 +1083,7 @@ describe('Project', () => { }); test('test method updateOAuth2Stripe()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'ca_UKibXX0000000000000000000006byvR', apiSecretKey: @@ -959,7 +1099,7 @@ describe('Project', () => { }); test('test method updateOAuth2TikTok()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'awz000000000tyw0', clientSecret: '6wXewM00000000000000000000yXnite', @@ -974,7 +1114,7 @@ describe('Project', () => { }); test('test method updateOAuth2Tradeshift()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -989,7 +1129,7 @@ describe('Project', () => { }); test('test method updateOAuth2TradeshiftSandbox()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, oauth2ClientId: 'appwrite-test-org.appwrite-test-app', oauth2ClientSecret: '7cb52700-0000-0000-0000-000000ca5b83', @@ -1004,7 +1144,7 @@ describe('Project', () => { }); test('test method updateOAuth2Twitch()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'vvi0in000000000000000000ikmt9p', clientSecret: 'pmapue000000000000000000zylw3v', @@ -1019,7 +1159,7 @@ describe('Project', () => { }); test('test method updateOAuth2Webflow()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '8bb20000000000000000000000000000000000000000000000000000000040dd', @@ -1036,7 +1176,7 @@ describe('Project', () => { }); test('test method updateOAuth2WordPress()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '130005', clientSecret: @@ -1052,7 +1192,7 @@ describe('Project', () => { }); test('test method updateOAuth2X()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, customerKey: 'slzZV0000000000000NFLaWT', secretKey: 'tkEPkp00000000000000000000000000000000000000FTxbI9', @@ -1067,7 +1207,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yahoo()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', @@ -1083,7 +1223,7 @@ describe('Project', () => { }); test('test method updateOAuth2Yandex()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '6a8a6a0000000000000000000091483c', clientSecret: 'bbf98500000000000000000000c75a63', @@ -1098,7 +1238,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoho()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '1000.83C178000000000000000000RPNX0B', clientSecret: 'fb5cac000000000000000000000000000000a68f6e', @@ -1114,7 +1254,7 @@ describe('Project', () => { }); test('test method updateOAuth2Zoom()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: 'QMAC00000000000000w0AQ', clientSecret: 'GAWsG4000000000000000000007U01ON', @@ -1129,7 +1269,7 @@ describe('Project', () => { }); test('test method getOAuth2Provider()', async () => { const data = { - '\\$id': 'github', + $id: 'github', enabled: true, clientId: '839ff5000000000000000000013206de', clientSecret: 'jLNVOK00000000000000000000yJebea', @@ -1158,12 +1298,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.createAndroidPlatform( @@ -1179,12 +1320,13 @@ describe('Project', () => { }); 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', + $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', + fingerprints: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.updateAndroidPlatform( @@ -1200,9 +1342,9 @@ describe('Project', () => { }); 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', + $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', @@ -1221,9 +1363,9 @@ describe('Project', () => { }); 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', + $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', @@ -1242,9 +1384,9 @@ describe('Project', () => { }); 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', + $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', @@ -1263,9 +1405,9 @@ describe('Project', () => { }); 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', + $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', @@ -1284,9 +1426,9 @@ describe('Project', () => { }); 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', + $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', @@ -1305,9 +1447,9 @@ describe('Project', () => { }); 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', + $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', @@ -1326,9 +1468,9 @@ describe('Project', () => { }); 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', + $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', @@ -1347,9 +1489,9 @@ describe('Project', () => { }); 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', + $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', @@ -1368,9 +1510,9 @@ describe('Project', () => { }); 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', + $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', @@ -1408,9 +1550,9 @@ describe('Project', () => { }); 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', + $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', @@ -1445,9 +1587,9 @@ describe('Project', () => { }); 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', + $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', @@ -1482,9 +1624,9 @@ describe('Project', () => { }); 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', + $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', @@ -1519,9 +1661,9 @@ describe('Project', () => { }); 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', + $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', @@ -1556,9 +1698,9 @@ describe('Project', () => { }); 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', + $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', @@ -1593,9 +1735,9 @@ describe('Project', () => { }); 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', + $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', @@ -1628,11 +1770,48 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasskeyPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasskeyPolicy('<RP_ID>'); + + // 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', + $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', @@ -1667,9 +1846,9 @@ describe('Project', () => { }); 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', + $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', @@ -1704,9 +1883,9 @@ describe('Project', () => { }); 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', + $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', @@ -1741,9 +1920,9 @@ describe('Project', () => { }); test('test method updatePasswordPwnedPolicy()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -1776,9 +1955,46 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updatePasswordRotationPolicy()', async () => { + const data = { + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'New Project', + teamId: '1592981250', + region: 'fra', + smtpEnabled: true, + smtpSenderName: 'John Appwrite', + smtpSenderEmail: 'john@appwrite.io', + smtpReplyToName: 'Support Team', + smtpReplyToEmail: 'support@appwrite.io', + smtpHost: 'mail.appwrite.io', + smtpPort: 25, + smtpUsername: 'emailuser', + smtpPassword: 'smtp-password', + smtpSecure: 'tls', + pingCount: 1, + pingedAt: '2020-10-15T06:38:00.000+00:00', + labels: [], + status: 'active', + onboarding: {}, + authMethods: [], + services: [], + protocols: [], + blocks: [], + consoleAccessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await project.updatePasswordRotationPolicy(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); test('test method updatePasswordStrengthPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', + $id: 'password-dictionary', min: 12, uppercase: true, lowercase: true, @@ -1795,9 +2011,9 @@ describe('Project', () => { }); 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', + $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', @@ -1832,9 +2048,9 @@ describe('Project', () => { }); 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', + $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', @@ -1869,9 +2085,9 @@ describe('Project', () => { }); 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', + $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', @@ -1906,9 +2122,9 @@ describe('Project', () => { }); 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', + $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', @@ -1943,9 +2159,9 @@ describe('Project', () => { }); 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', + $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', @@ -1980,8 +2196,9 @@ describe('Project', () => { }); test('test method getPolicy()', async () => { const data = { - '\\$id': 'password-dictionary', - enabled: true, + $id: 'password-dictionary', + rpId: 'example.com', + origins: [], }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.getPolicy('password-dictionary'); @@ -1993,9 +2210,9 @@ describe('Project', () => { }); 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', + $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', @@ -2030,9 +2247,9 @@ describe('Project', () => { }); 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', + $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', @@ -2067,9 +2284,9 @@ describe('Project', () => { }); 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', + $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', @@ -2178,9 +2395,9 @@ describe('Project', () => { }); 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', + $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, @@ -2201,9 +2418,9 @@ describe('Project', () => { }); 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', + $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, @@ -2220,9 +2437,9 @@ describe('Project', () => { }); 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', + $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, diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js index bf9d288..3445b18 100644 --- a/test/services/proxy.test.js +++ b/test/services/proxy.test.js @@ -41,9 +41,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -55,6 +55,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createAPIRule('example.com'); @@ -66,9 +67,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -80,6 +81,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createFunctionRule( @@ -94,9 +96,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -108,6 +110,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createRedirectRule( @@ -125,9 +128,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -139,6 +142,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.createSiteRule('example.com', '<SITE_ID>'); @@ -148,11 +152,40 @@ describe('Proxy', () => { expect(response).toEqual(data); }); + test('test method createSMTPRule()', 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', + protocol: 'http', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await proxy.createSMTPRule( + 'example.com', + '<FUNCTION_ID>', + ); + + // 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', + $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', @@ -164,6 +197,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.getRule('<RULE_ID>'); @@ -185,9 +219,9 @@ describe('Proxy', () => { }); 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', + $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', @@ -199,6 +233,7 @@ describe('Proxy', () => { 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', + protocol: 'http', }; mockedFetch.mockImplementation(() => Response.json(data)); const response = await proxy.updateRuleStatus('<RULE_ID>'); diff --git a/test/services/sites.test.js b/test/services/sites.test.js index 8e558d9..cf30e82 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -27,9 +27,9 @@ describe('Sites', () => { }); 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', + $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, @@ -104,9 +104,9 @@ describe('Sites', () => { }); 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', + $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, @@ -150,9 +150,9 @@ describe('Sites', () => { }); 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', + $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, @@ -206,9 +206,9 @@ describe('Sites', () => { }); 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', + $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, @@ -268,9 +268,9 @@ describe('Sites', () => { }); 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', + $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', @@ -312,9 +312,9 @@ describe('Sites', () => { }); 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', + $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', @@ -356,9 +356,9 @@ describe('Sites', () => { }); 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', + $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', @@ -404,9 +404,9 @@ describe('Sites', () => { }); 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', + $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', @@ -449,9 +449,9 @@ describe('Sites', () => { }); 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', + $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', @@ -519,9 +519,9 @@ describe('Sites', () => { }); 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', + $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', @@ -576,10 +576,10 @@ describe('Sites', () => { }); 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': [], + $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', @@ -628,9 +628,9 @@ describe('Sites', () => { }); 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', + $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, @@ -652,9 +652,9 @@ describe('Sites', () => { }); 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', + $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, @@ -671,9 +671,9 @@ describe('Sites', () => { }); 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', + $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, diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 7f35319..b46b168 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -27,10 +27,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -52,10 +52,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -77,10 +77,10 @@ describe('Storage', () => { }); 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': [], + $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, @@ -125,11 +125,11 @@ describe('Storage', () => { }); test('test method createFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -156,11 +156,11 @@ describe('Storage', () => { }); test('test method getFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', @@ -183,11 +183,11 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', bucketId: '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\\$permissions': [], + $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', diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 1c1cf2f..6320233 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -26,10 +26,10 @@ describe('TablesDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('TablesDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('TablesDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -191,21 +191,17 @@ describe('TablesDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, @@ -265,9 +261,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -296,9 +292,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -340,9 +336,9 @@ describe('TablesDB', () => { }); test('test method createCutover()', async () => { const data = { - '\\$id': '5e5ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -436,10 +432,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -463,10 +459,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -486,10 +482,10 @@ describe('TablesDB', () => { }); 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': [], + $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, @@ -546,8 +542,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -569,8 +565,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -593,8 +589,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -616,8 +612,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -640,8 +636,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -664,8 +660,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -689,8 +685,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -713,8 +709,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -738,8 +734,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -764,8 +760,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', elements: [], format: 'enum', }; @@ -791,8 +787,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -814,8 +810,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -838,8 +834,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -861,8 +857,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -885,8 +881,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -909,8 +905,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -934,8 +930,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -957,8 +953,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -980,8 +976,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1003,8 +999,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1027,8 +1023,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1050,8 +1046,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1074,8 +1070,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1097,8 +1093,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1120,8 +1116,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1143,8 +1139,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1166,8 +1162,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1195,8 +1191,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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, @@ -1223,8 +1219,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1248,8 +1244,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1273,8 +1269,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1296,8 +1292,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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( @@ -1320,8 +1316,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1344,8 +1340,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1369,8 +1365,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1394,8 +1390,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1419,8 +1415,8 @@ describe('TablesDB', () => { status: 'available', error: 'string', required: true, - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $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)); @@ -1467,9 +1463,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1493,9 +1489,9 @@ describe('TablesDB', () => { }); 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', + $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', @@ -1544,13 +1540,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1633,13 +1629,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1655,13 +1651,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1677,13 +1673,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1713,13 +1709,13 @@ describe('TablesDB', () => { }); 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': [], + $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( @@ -1736,13 +1732,13 @@ describe('TablesDB', () => { }); 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': [], + $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( diff --git a/test/services/teams.test.js b/test/services/teams.test.js index 7dcf744..0248491 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -26,9 +26,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -43,9 +43,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -60,9 +60,9 @@ describe('Teams', () => { }); 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', + $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: {}, @@ -100,9 +100,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -123,9 +123,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -146,9 +146,9 @@ describe('Teams', () => { }); 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', + $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: [], @@ -195,9 +195,9 @@ describe('Teams', () => { }); 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', + $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', @@ -221,9 +221,9 @@ describe('Teams', () => { }); 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', + $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', @@ -250,9 +250,9 @@ describe('Teams', () => { }); 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', + $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', @@ -293,9 +293,9 @@ describe('Teams', () => { }); 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', + $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', diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index 323ab93..1850b2e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -26,8 +26,8 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -47,8 +47,8 @@ describe('Tokens', () => { }); test('test method get()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', @@ -65,8 +65,8 @@ describe('Tokens', () => { }); test('test method update()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $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', diff --git a/test/services/users.test.js b/test/services/users.test.js index 3123510..21befd9 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -26,9 +26,9 @@ describe('Users', () => { }); 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', + $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, @@ -53,9 +53,9 @@ describe('Users', () => { }); 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', + $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, @@ -84,9 +84,9 @@ describe('Users', () => { }); 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', + $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, @@ -138,9 +138,9 @@ describe('Users', () => { }); 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', + $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, @@ -169,9 +169,9 @@ describe('Users', () => { }); 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', + $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, @@ -200,9 +200,9 @@ describe('Users', () => { }); 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', + $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, @@ -236,9 +236,9 @@ describe('Users', () => { }); 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', + $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, @@ -270,9 +270,9 @@ describe('Users', () => { }); 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', + $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, @@ -301,9 +301,9 @@ describe('Users', () => { }); 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', + $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, @@ -338,9 +338,9 @@ describe('Users', () => { }); 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', + $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, @@ -368,9 +368,9 @@ describe('Users', () => { }); 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', + $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, @@ -407,9 +407,9 @@ describe('Users', () => { }); 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', + $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, @@ -447,9 +447,9 @@ describe('Users', () => { }); 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', + $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, @@ -474,9 +474,9 @@ describe('Users', () => { }); 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', + $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, @@ -527,8 +527,8 @@ describe('Users', () => { }); test('test method getMFAChallenge()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', expire: '2020-10-15T06:38:00.000+00:00', code: '446372', @@ -650,9 +650,9 @@ describe('Users', () => { }); 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', + $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, @@ -675,11 +675,70 @@ describe('Users', () => { expect(response).toEqual(data); }); + test('test method listPasskeys()', async () => { + const data = { + total: 5, + passkeys: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.listPasskeys('<USER_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getPasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.getPasskey('<USER_ID>', '<PASSKEY_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updatePasskey()', 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 laptop', + accessedAt: '2020-10-15T06:38:00.000+00:00', + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.updatePasskey( + '<USER_ID>', + '<PASSKEY_ID>', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deletePasskey()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await users.deletePasskey('<USER_ID>', '<PASSKEY_ID>'); + + // 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', + $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, @@ -704,9 +763,9 @@ describe('Users', () => { }); 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', + $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, @@ -764,9 +823,9 @@ describe('Users', () => { }); 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', + $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', @@ -824,9 +883,9 @@ describe('Users', () => { }); 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', + $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, @@ -864,9 +923,9 @@ describe('Users', () => { }); 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', + $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', @@ -888,9 +947,9 @@ describe('Users', () => { }); 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', + $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', @@ -907,9 +966,9 @@ describe('Users', () => { }); 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', + $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', @@ -936,8 +995,8 @@ describe('Users', () => { }); test('test method createToken()', async () => { const data = { - '\\$id': 'bb8ea5c16897e', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', @@ -953,9 +1012,9 @@ describe('Users', () => { }); 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', + $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, @@ -980,9 +1039,9 @@ describe('Users', () => { }); 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', + $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, diff --git a/test/services/vectors-d-b.test.js b/test/services/vectors-d-b.test.js index 3df11da..4fe8681 100644 --- a/test/services/vectors-d-b.test.js +++ b/test/services/vectors-d-b.test.js @@ -26,10 +26,10 @@ describe('VectorsDB', () => { }); test('test method create()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -69,9 +69,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -86,9 +86,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -103,9 +103,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -130,9 +130,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -147,10 +147,10 @@ describe('VectorsDB', () => { }); test('test method get()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -164,10 +164,10 @@ describe('VectorsDB', () => { }); test('test method update()', async () => { const data = { - '\\$id': '5e5ea5c16897e', + $id: '5e5ea5c16897e', name: 'My Database', - '\\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\\$updatedAt': '2020-10-15T06:38:00.000+00:00', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', enabled: true, type: 'legacy', }; @@ -204,10 +204,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -233,10 +233,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -260,10 +260,10 @@ describe('VectorsDB', () => { }); 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': [], + $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, @@ -317,13 +317,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -422,13 +422,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -444,13 +444,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -466,13 +466,13 @@ describe('VectorsDB', () => { }); 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': [], + $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( @@ -518,9 +518,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -544,9 +544,9 @@ describe('VectorsDB', () => { }); 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', + $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', @@ -582,21 +582,17 @@ describe('VectorsDB', () => { }); 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', + $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: '••••••••', - credentialGeneration: 1, connectionString: 'postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require', ssl: true, diff --git a/test/services/waf.test.js b/test/services/waf.test.js new file mode 100644 index 0000000..1e672a2 --- /dev/null +++ b/test/services/waf.test.js @@ -0,0 +1,354 @@ +const { Client } = require('../../dist/client'); +const { Waf } = require('../../dist/services/waf'); + +const { fetch: mockedFetch, Response } = require('undici'); +jest.mock('undici', () => ({ + ...jest.requireActual('undici'), + fetch: jest.fn(), +})); + +describe('Waf', () => { + const client = new Client(); + const waf = new Waf(client); + + test('test method listRules()', async () => { + const data = { + total: 5, + rules: [], + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.listRules(); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createBypassRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateBypassRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateBypassRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createChallengeRule( + '<RULE_ID>', + 'api', + '<NAME>', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateChallengeRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: 'compute', + difficulty: 3, + ttl: 1800, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateChallengeRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createDenyRule('<RULE_ID>', 'api', '<NAME>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateDenyRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateDenyRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRateLimitRule( + '<RULE_ID>', + 'api', + '<NAME>', + 1, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRateLimitRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: 'userId', + strategy: 'slidingWindow', + maxBucketSize: 200, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRateLimitRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.createRedirectRule( + '<RULE_ID>', + 'api', + '<NAME>', + '<LOCATION>', + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method updateRedirectRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.updateRedirectRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method getRule()', async () => { + const data = { + $id: 'wafRule1', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Block anonymous POST traffic', + description: 'Blocks anonymous POST calls to /v1/graphql', + teamId: '5e5ea5c16897e', + projectId: 'cloudConsole', + resourceType: 'functions', + resourceId: 'functionId', + action: 'deny', + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: '/maintenance', + statusCode: 301, + }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.getRule('<RULE_ID>'); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method deleteRule()', async () => { + const data = { message: '' }; + mockedFetch.mockImplementation(() => Response.json(data)); + const response = await waf.deleteRule('<RULE_ID>'); + + // 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 7f7e54b..d232fb5 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -26,9 +26,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -55,9 +55,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -79,9 +79,9 @@ describe('Webhooks', () => { }); 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', + $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: [], @@ -118,9 +118,9 @@ describe('Webhooks', () => { }); 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', + $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: [], diff --git a/test/topic.test.js b/test/topic.test.js index 44ba8cd..fc5d764 100644 --- a/test/topic.test.js +++ b/test/topic.test.js @@ -9,24 +9,10 @@ describe('Topic', () => { expect(Topic.path(['user']).path(['notification']).toString()).toEqual( 'user/notification', ); - }); - test('any', () => { - expect( - Topic.path(['user']).any().path(['notification']).toString(), - ).toEqual('user/+/notification'); - expect( - Topic.path(['chat']).any().any().path(['message']).toString(), - ).toEqual('chat/+/+/message'); - expect(Topic.any().path(['notification']).toString()).toEqual( - '+/notification', + expect(Topic.path(['org', '42']).path(['logs']).toString()).toEqual( + 'org/42/logs', ); }); - test('all', () => { - expect( - Topic.path(['org']).any().path(['logs']).all().toString(), - ).toEqual('org/+/logs/#'); - expect(Topic.all().toString()).toEqual('#'); - }); test.each([ ['an empty path', []], ['an empty level', ['user', '']], @@ -35,10 +21,11 @@ describe('Topic', () => { ['an embedded +', ['user', 'a+b']], ['a lone #', ['user', '#']], ['an embedded #', ['user', 'a#b']], + ['a NUL character', ['user', 'a\u0000b']], ['a non-string level', ['user', null]], ['a non-array', 'user'], ])('rejects %s', (_, levels) => { expect(() => Topic.path(levels)).toThrow(Error); - expect(() => Topic.any().path(levels)).toThrow(Error); + expect(() => Topic.path(['user']).path(levels)).toThrow(Error); }); });